Error memcpy was not declared in this scope

I'm trying to build an open source c++ library with gcc and eclipse. But I get this error ‘memcpy’ was not declared in this scope I've try to include memory.h (and string.h) and eclipse find the

I’m trying to build an open source c++ library with gcc and eclipse.
But I get this error
‘memcpy’ was not declared in this scope

I’ve try to include memory.h (and string.h) and eclipse find the function if I click «open declaration» but gcc give me the error.

How can I do?

#include <algorithm>
#include <memory.h>

namespace rosic
{
   //etc etc
template <class T>
  void circularShift(T *buffer, int length, int numPositions)
  {
    int na = abs(numPositions);
    while( na > length )
      na -=length;
    T *tmp = new T[na];
    if( numPositions < 0 )
    {

      memcpy(  tmp,                buffer,              na*sizeof(T));
      memmove( buffer,            &buffer[na], (length-na)*sizeof(T));
      memcpy( &buffer[length-na],  tmp,                 na*sizeof(T));
    }
    else if( numPositions > 0 )
    {
      memcpy(  tmp,        &buffer[length-na],          na*sizeof(T));
      memmove(&buffer[na],  buffer,            (length-na)*sizeof(T));
      memcpy(  buffer,      tmp,                        na*sizeof(T));
    }
    delete[] tmp;
  }

//etc etc
}

I get error on each memcpy and memmove function.

Please state the information for your system

  • OpenCV version: 3.0/3.1/master
  • Host OS: Linux (Ubuntu 16.04)
  • Compiler: GCC 4.7/4.8/4.9/5.0
  • CUDA 7.5 (from synaptic package manager («nvidia-cuda-toolkit»))

In which part of the OpenCV library you got the issue?

  • cuda

When trying to compile opencv (ubuntu 16.04) i get the following error:

[ 9%] Building NVCC (Device) object modules/core/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_gpu_mat.cu.o
/usr/include/string.h: In function ‘void* mempcpy_inline(void, const void, size_t)’:
/usr/include/string.h:652:42: error: ‘memcpy’ was not declared in this scope
return (char *) memcpy (__dest, __src, __n) + __n;
^
CMake Error at cuda_compile_generated_gpu_mat.cu.o.cmake:264 (message):
Error generating file
/home/mag/opencv/build_opencv_master/modules/core/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_gpu_mat.cu.o

The problem is known, but you need to make a workaround to support cuda. Here is a link to the same Proplem in the caffe git, but unfortunetly the solution doesnt work for me:
BVLC/caffe#4046

  • Forum
  • UNIX/Linux Programming
  • compiling c++ programs in ubuntu g++

compiling c++ programs in ubuntu g++

hi every one i am new to c++ programming. i got an error as shown below

«root@ubuntu:/home/ramreddy/Desktop/tts/speech_tools# make
Making in directory ./siod …
gcc -c -fno-implicit-templates -O3 -Wall -DSUPPORT_EDITLINE -I../include slib.cc
In file included from ../include/EST_String.h:50:0,
from ../include/siod.h:17,
from slib.cc:88:
../include/EST_iostream.h:53:25: fatal error: iostream.h: No such file or directory
compilation terminated.»

please help me is there any lib file is missing or any other

thanks in advance

Working as root?

iostream.h is deprecated. It’s part of the old I/O Stream library and was replaced by the C++98 standard.

The replacement is

hi,
thanks for the response. initially i got an error as

../../include/../base_class/EST_TSimpleMatrix.cc:54:5: error: ‘memcpy’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
In file included from /usr/include/string.h:642:0,
from /usr/include/c++/4.7/cstring:44,
from ../../include/EST_String.h:42,
from ../../include/EST_error.h:182,
from ../../include/../base_class/EST_TMatrix.cc:48,
from matrix_i_t.cc:50:
/usr/include/i386-linux-gnu/bits/string3.h:49:1: note: ‘void* memcpy(void*, const void*, size_t)’ declared here, later in the translation unit
make[2]: *** [matrix_i_t.o] Error 1
make[1]: *** [inst_tmpl] Error 2
make: *** [base_class] Error 2

please help me
thanks.

Include <cstring> before using memcpy.

thank you it worked

Topic archived. No new replies allowed.

  • Печать

Страницы: [1]   Вниз

Тема: Проблемы при сборке, помогите решить  (Прочитано 3249 раз)

0 Пользователей и 1 Гость просматривают эту тему.

Оффлайн
Costa

День добрый!
Собираю тут одну программку и никак не могу взять в толк, где грабли.
Под виндой в Dev-C++ 4.9.9.2 собирается без проблем вот так:

g++ -c AES.cpp -o AES.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"
Под Убунтой, собирая вот так (так у приятеля без проблем собирается, правда на другом дистре):

g++ -c AES.cpp -o AES.oполучаю такие грабли:

In file included from DataBuffer.h:27,
from AES.h:21,
from AES.cpp:18:
ByteString.h: In static member function ‘static int std::char_traits::compare(const unsigned char*, const unsigned char*, size_t)’:
ByteString.h:35: error: ‘memcmp’ was not declared in this scope
ByteString.h: In static member function ‘static unsigned char* std::char_traits::copy(unsigned char*, const unsigned char*, size_t)’:
ByteString.h:39: error: ‘memcpy’ was not declared in this scope
ByteString.h: In static member function ‘static unsigned char* std::char_traits::move(unsigned char*, const unsigned char*, size_t)’:
ByteString.h:43: error: ‘memmove’ was not declared in this scope
ByteString.h: In static member function ‘static unsigned char* std::char_traits::assign(unsigned char*, size_t, char)’:
ByteString.h:47: error: ‘memset’ was not declared in this scope
ByteString.h: In static member function ‘static const unsigned char* std::char_traits::find(const unsigned char*, size_t, const char&)’:
ByteString.h:51: error: ‘memchr’ was not declared in this scope
ByteString.h: In static member function ‘static int std::char_traits::eof()’:
ByteString.h:55: error: ‘EOF’ was not declared in this scope
ByteString.h: In static member function ‘static int std::char_traits::not_eof(const int&)’:
ByteString.h:67: error: ‘EOF’ was not declared in this scope

Чего же ему надо? Может надо какой пакет доставить или вручную пути к инклудам прописать? Посоветуйте.

ByteString.h

Чуть более подробные исходники — во вложении.


Оффлайн
Mam(O)n

Не хватает

#include <cstring>
#include <cstdio>


Оффлайн
Costa

Mam(O)n, спасибо, помогло!

Правда, повылезали warnings, почти все поубирал, но осталось пара настырных.

Вот здесь (фрагмент исходников) первая строчка выдает
warning: deprecated conversion from string constant to ‘char*’

char *keyString = "KEYx";
keyString[3] = i - 1 + '1';

И то же самое предупреждение во второй строчке:

DataBuffer var;
var = "bla-bla-bla";
DataBuffer во вложении.

Как это исправить?


Оффлайн
wl

По новым правилам GCC строка должна быть const.

http://www.daniweb.com/forums/thread156711.html

int main(void) {
  char *keyString1 = "KEYx";
  char keyString2[] = "KEYx";
  const char *keyString3 = "KEYx";
  return 0;
}

$ g++ string_constant.c
string_constant.c: In function ‘int main()’:
string_constant.c:2: warning: deprecated conversion from string constant to ‘char*’

Т.е. на первую строку выдается предупреджение, на остальные — нет. У g++ есть ключ для отключения этого предупреждения.

« Последнее редактирование: 13 Января 2010, 12:27:43 от wl »

На свете феньки есть такие, брат Горацио, которых лохи просто не секут. (Шекспир, «Гамлет», вольный перевод)


Оффлайн
Costa

Сделал так:

char keyString[] = "KEYx";проходит.

А второе как поправить? Отключать предупреждения не хотелось бы, мало ли потом какие баги попрут.


Оффлайн
wl

Недосуг мне скачивать архив, распаковывать его и лазить по тексту.
Если тип DataBuffer объявлен как-нибудь наподобие char * или char[ ], то вообще-то надо бы использовать strdup или strcpy.
Если это string, тогда можно написать string(«blah-blah-blah»);

На будущее рекомендую пользоваться spoiler-ами здесь или http://pastebin.com

На свете феньки есть такие, брат Горацио, которых лохи просто не секут. (Шекспир, «Гамлет», вольный перевод)


Оффлайн
alexander.pronin

А второе как поправить? Отключать предупреждения не хотелось бы, мало ли потом какие баги попрут.

В классе DataBuffer у Вас такие конструкторы.
   DataBuffer();

   DataBuffer(const DataBuffer& buffer);

   DataBuffer(const char *hexString);

   DataBuffer(const char *hexString, size_t length);

   DataBuffer(const unsigned char *data, size_t length);

   DataBuffer(size_t size, unsigned char fill = 0);

Какой соответствует Вашему объявлению ? 8)


Оффлайн
wl

А оператора = перегруженного там нет?

На свете феньки есть такие, брат Горацио, которых лохи просто не секут. (Шекспир, «Гамлет», вольный перевод)


Оффлайн
Costa

Кстати, есть:

DataBuffer& operator =(const DataBuffer& buffer);
DataBuffer& operator =(char *rvalue);
DataBuffer& operator =(const ByteString& string);

//=============================================================================
// Assignment operator for rvalue of type DataBuffer

DataBuffer& DataBuffer::operator = (const DataBuffer& buffer)
{
deleteHexString();

ByteString::operator=(buffer);

return *this;
}

//=============================================================================
// Assignment operator for rvalue of type char * (that is, string)

DataBuffer& DataBuffer::operator = (char *rvalue)
{
parse(rvalue, strlen(rvalue));

return *this;
}

//=============================================================================
// Assignment operator for rvalue of type ByteString

DataBuffer& DataBuffer::operator = (const ByteString& string)
{
ByteString::operator =(string);

return *this;
}


Спасибо за наводку, сейчас попробую сам дотумкать! :) В C++ я не очень мастак, в основном C, а код изначально написан Атмелом.


Пользователь решил продолжить мысль 13 Января 2010, 13:17:36:


Все сделал, огромное все спасибо!

DataBuffer& operator =(char const *rvalue);

//=============================================================================
// Assignment operator for rvalue of type char * (that is, string)

DataBuffer& DataBuffer::operator = (char const *rvalue)
{
parse(rvalue, strlen(rvalue));

return *this;
}

« Последнее редактирование: 13 Января 2010, 13:17:36 от Costa »


  • Печать

Страницы: [1]   Вверх

View previous topic :: View next topic  
Author Message
audiodef
Watchman
Watchman

Joined: 06 Jul 2005
Posts: 6538
Location: /usr/lib64/lv2

PostPosted: Fri Apr 16, 2010 4:54 pm    Post subject: libdsp won’t compile, memcpy not declared Reply with quote

When trying to emerge libdsp, I get the following error. Can someone tell me why this happens and what I can do to fix it? Could it be as easy as adding a missing include?

Code:

In file included from ./dsp/DSPOp.hh:30,

                 from dsp/FFTInterpolator.hh:23,

                 from FFTInterpolator.cc:31:

../Inlines/Alloc.hh: In member function ‘void* clAlloc::Resize(long int)’:

../Inlines/Alloc.hh:142: error: ‘memcpy’ was not declared in this scope

../Inlines/Alloc.hh: In member function ‘void clAlloc::Copy(const clAlloc&)’:

../Inlines/Alloc.hh:226: error: ‘memcpy’ was not declared in this scope

make: *** [FFTInterpolator.o] Error 1

make: *** Waiting for unfinished jobs….

In file included from ./dsp/DSPOp.hh:30,

                 from dsp/FFTDecimator.hh:23,

                 from FFTDecimator.cc:31:

../Inlines/Alloc.hh: In member function ‘void* clAlloc::Resize(long int)’:

../Inlines/Alloc.hh:142: error: ‘memcpy’ was not declared in this scope

../Inlines/Alloc.hh: In member function ‘void clAlloc::Copy(const clAlloc&)’:

../Inlines/Alloc.hh:226: error: ‘memcpy’ was not declared in this scope

make: *** [FFTDecimator.o] Error 1

In file included from dsp/DSPOp.hh:30,

                 from DSPOp.cc:41:

../Inlines/Alloc.hh: In member function ‘void* clAlloc::Resize(long int)’:

../Inlines/Alloc.hh:142: error: ‘memcpy’ was not declared in this scope

../Inlines/Alloc.hh: In member function ‘void clAlloc::Copy(const clAlloc&)’:

../Inlines/Alloc.hh:226: error: ‘memcpy’ was not declared in this scope

DSPOp.cc: In static member function ‘static void clDSPOp::Copy(float*, const float*, long int)’:

DSPOp.cc:2863: error: ‘memmove’ was not declared in this scope

DSPOp.cc: In static member function ‘static void clDSPOp::Copy(double*, const double*, long int)’:

DSPOp.cc:2915: error: ‘memmove’ was not declared in this scope

DSPOp.cc: In static member function ‘static void clDSPOp::Copy(_sSCplx*, _sSCplx*, long int)’:

DSPOp.cc:2972: error: ‘memmove’ was not declared in this scope

DSPOp.cc: In static member function ‘static void clDSPOp::Copy(_sDCplx*, _sDCplx*, long int)’:

DSPOp.cc:3026: error: ‘memmove’ was not declared in this scope

make: *** [DSPOp.o] Error 1

 * ERROR: media-libs/libdsp-5.0.2 failed:

 *   libDSP make failed!

 *

 * Call stack:

 *     ebuild.sh, line  48:  Called src_compile

 *   environment, line 2500:  Called die

 * The specific snippet of code:

 *       emake ${myconf} || die «libDSP make failed!»

 *

 * If you need support, post the output of ’emerge —info =media-libs/libdsp-5.0.2′,

 * the complete build log and the output of ’emerge -pqv =media-libs/libdsp-5.0.2′.

 * This ebuild used the following eclasses from overlays:

 *   /var/lib/layman/pro-audio/eclass/exteutils.eclass

 * This ebuild is from an overlay named ‘proaudio’: ‘/var/lib/layman/pro-audio/’

 * The complete build log is located at ‘/var/tmp/portage/media-libs/libdsp-5.0.2/temp/build.log’.

 * The ebuild environment file is located at ‘/var/tmp/portage/media-libs/libdsp-5.0.2/temp/environment’.

 * S: ‘/var/tmp/portage/media-libs/libdsp-5.0.2/work/libdsp-src-5.0.2’


_________________
Gentoo Studio: A Gentoo-based, professional digital audio workstation OS.

Back to top

View user's profile Send private message

VoidMage
Watchman
Watchman

Joined: 14 Oct 2006
Posts: 6194

PostPosted: Fri Apr 16, 2010 5:50 pm    Post subject: Reply with quote

First question would be: what overlay is it ?

But taking a guess, it’s probably a missing ‘#include <cstring>’
Back to top

View user's profile Send private message

Hu
Moderator
Moderator

Joined: 06 Mar 2007
Posts: 19773

PostPosted: Fri Apr 16, 2010 11:01 pm    Post subject: Re: libdsp won’t compile, memcpy not declared Reply with quote

VoidMage wrote:
First question would be: what overlay is it ?



audiodef wrote:
Code:
 * This ebuild used the following eclasses from overlays:

 *   /var/lib/layman/pro-audio/eclass/exteutils.eclass

 * This ebuild is from an overlay named ‘proaudio’: ‘/var/lib/layman/pro-audio/’

Back to top

View user's profile Send private message

audiodef
Watchman
Watchman

Joined: 06 Jul 2005
Posts: 6538
Location: /usr/lib64/lv2

PostPosted: Sat Apr 17, 2010 2:35 pm    Post subject: Reply with quote

That was a good guess! With that issue solved, it moves on to:

Code:

X86-64.c: In function ‘dsp_x86_64_iirf’:

X86-64.c:318: error: impossible constraint in ‘asm’

make: *** [X86-64.o] Error 1

make: *** Waiting for unfinished jobs….

 * ERROR: media-libs/libdsp-5.0.2 failed:

 *   libDSP make failed!

 *

 * Call stack:

 *     ebuild.sh, line  48:  Called src_compile

 *   environment, line 2500:  Called die

 * The specific snippet of code:

 *       emake ${myconf} || die «libDSP make failed!»

 *

 * If you need support, post the output of ’emerge —info =media-libs/libdsp-5.0.2′,

 * the complete build log and the output of ’emerge -pqv =media-libs/libdsp-5.0.2′.

 * This ebuild used the following eclasses from overlays:

 *   /var/lib/layman/pro-audio/eclass/exteutils.eclass

 * This ebuild is from an overlay named ‘proaudio’: ‘/var/lib/layman/pro-audio/’

 * The complete build log is located at ‘/var/tmp/portage/media-libs/libdsp-5.0.2/temp/build.log’.

 * The ebuild environment file is located at ‘/var/tmp/portage/media-libs/libdsp-5.0.2/temp/environment’.

 * S: ‘/var/tmp/portage/media-libs/libdsp-5.0.2/work/libdsp-src-5.0.2’

Will an include in this file take care of it?
_________________
Gentoo Studio: A Gentoo-based, professional digital audio workstation OS.

Back to top

View user's profile Send private message

Hu
Moderator
Moderator

Joined: 06 Mar 2007
Posts: 19773

PostPosted: Sat Apr 17, 2010 4:46 pm    Post subject: Reply with quote

audiodef wrote:
That was a good guess! With that issue solved

What was the solution? I only pointed out that you had already answered the question asked by VoidMage.

audiodef wrote:
Code:

X86-64.c: In function ‘dsp_x86_64_iirf’:

X86-64.c:318: error: impossible constraint in ‘asm’

make: *** [X86-64.o] Error 1

Will an include in this file take care of it?

No. This is a problem brought about by compiling a particular construct with a tuple of compiler version, configuration, and $CFLAGS that is incompatible with the construct in question. The construct will need to be changed, which requires at least some programming knowledge. Since it is an asm constraint, some knowledge of the affected area would also be helpful.

Back to top

View user's profile Send private message

VoidMage
Watchman
Watchman

Joined: 14 Oct 2006
Posts: 6194

PostPosted: Sat Apr 17, 2010 5:40 pm    Post subject: Reply with quote

Frankly, I’m positive, this is simply a porting problem.

Missing ‘#include <cstring>’ was a common gcc 4.4 porting problem,

I suspect this asm problem will be something similar.
Back to top

View user's profile Send private message

Display posts from previous:   

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Ubuntu Linux 16.04 LTS with GEForce GTX-950 GPU X86_64

Trying to build OpenCV on Ubuntu 16.04, make fails with an error compiling cuda file:

**[ 16%] Building NVCC (Device) object modules/core/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_gpu_mat.cu.o
/usr/include/string.h: In function ‘void* __mempcpy_inline(void*, const void*, size_t)’:
/usr/include/string.h:652:42: error: ‘memcpy’ was not declared in this scope
   return (char *) memcpy (__dest, __src, __n) + __n;
                                          ^
CMake Error at cuda_compile_generated_gpu_mat.cu.o.cmake:266 (message):
  Error generating file
  /home/johann/Downloads/opencv-3.1.0/release/modules/core/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_gpu_mat.cu.o
modules/core/CMakeFiles/opencv_core.dir/build.make:63: recipe for target** 'modules/core/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_gpu_mat.cu.o' failed
make[2]: *** [modules/core/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_gpu_mat.cu.o] Error 1
CMakeFiles/Makefile2:1722: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/all' failed
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2


Below is the output from the CMAKE configuration step:

[email protected]:~/Downloads/opencv-3.1.0/release$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON ..
-- Detected version of GNU GCC: 54 (504)
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found suitable version "1.2.8", minimum required is "1.2.3") 
-- Could NOT find TIFF (missing:  TIFF_LIBRARY TIFF_INCLUDE_DIR) 
-- Could NOT find JPEG (missing:  JPEG_LIBRARY JPEG_INCLUDE_DIR) 
-- Could NOT find Jasper (missing:  JASPER_LIBRARIES JASPER_INCLUDE_DIR) 
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8") 
-- Checking for module 'gstreamer-base-1.0'
--   No package 'gstreamer-base-1.0' found
-- Checking for module 'gstreamer-video-1.0'
--   No package 'gstreamer-video-1.0' found
-- Checking for module 'gstreamer-app-1.0'
--   No package 'gstreamer-app-1.0' found
-- Checking for module 'gstreamer-riff-1.0'
--   No package 'gstreamer-riff-1.0' found
-- Checking for module 'gstreamer-pbutils-1.0'
--   No package 'gstreamer-pbutils-1.0' found
-- Checking for module 'gstreamer-base-0.10'
--   No package 'gstreamer-base-0.10' found
-- Checking for module 'gstreamer-video-0.10'
--   No package 'gstreamer-video-0.10' found
-- Checking for module 'gstreamer-app-0.10'
--   No package 'gstreamer-app-0.10' found
-- Checking for module 'gstreamer-riff-0.10'
--   No package 'gstreamer-riff-0.10' found
-- Checking for module 'gstreamer-pbutils-0.10'
--   No package 'gstreamer-pbutils-0.10' found
-- Checking for module 'libdc1394-2'
--   No package 'libdc1394-2' found
-- Checking for module 'libdc1394'
--   No package 'libdc1394' found
-- Checking for module 'libv4l1'
--   No package 'libv4l1' found
-- Checking for module 'libv4l2'
--   No package 'libv4l2' found
-- Looking for linux/videodev.h
-- Looking for linux/videodev.h - not found
-- Looking for linux/videodev2.h
-- Looking for linux/videodev2.h - found
-- Looking for sys/videoio.h
-- Looking for sys/videoio.h - not found
-- Checking for module 'libavresample'
--   No package 'libavresample' found
-- Looking for libavformat/avformat.h
-- Looking for libavformat/avformat.h - found
-- Looking for ffmpeg/avformat.h
-- Looking for ffmpeg/avformat.h - not found
-- Checking for module 'libgphoto2'
--   No package 'libgphoto2' found
-- found IPP (ICV version): 9.0.1 [9.0.1]
-- at: /home/johann/Downloads/opencv-3.1.0/3rdparty/ippicv/unpack/ippicv_lnx
-- CUDA detected: 7.5
-- CUDA NVCC target flags: -gencode;arch=compute_20,code=sm_20;-gencode ...

(more)

Actually I get this error if I try to build all CUDA architectures. Instead I just change 2 CMAKE variables, CUDA_ARCH_BIN and CUDA_ARCH_PTX, to only contain the CUDA compute capability supported by my graphics card, which can be found here.

i have tried it on two pc’s but it doesnt’ work for me

Edit:
i have tried it with a Geforce GTX 980 and a Geforce GTX 780. so generation is kepler (and Maxwell) with architecture 3.0 3.5

if nessesary i can try it on other pc too. But for the next two weeks i can let one pc in this configuration, if you need more testing.

One fast workaround is to use as «CUDA_HOST_COMPILER» the «clang-3.5»

@StevenEWright Hey, can you give an example what exactly you changed in -DCUDA_ARCH_BIN=xx and `-DCUDA_ARCH_PTX=xx? I am using Nvidia 940M and I can’t find in the link you posted how to deduce from the product page what version I should include.

The Geforce 940m is 5.0 compatible.

@jamesapollo2016 I understand it uses CUDA Compute 5.0, but what what should I insert in -DCUDA_ARCH_BIN=xx and -DCUDA_ARCH_PTX=xx ? The options seem to be 20 21 30 35, not 5.

This is what I get if I set no changes:

--   NVIDIA CUDA
--     Use CUFFT:                   YES
--     Use CUBLAS:                  NO
--     USE NVCUVID:                 NO
--     NVIDIA GPU arch:             20 21 30 35
--     NVIDIA PTX archs:            30
--     Use fast math:               NO

I tried all combinations of
cmake -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules/ -DBUILD_opencv_legacy=OFF -DCUDA_ARCH_BIN=2.0 -DCUDA_ARCH_PTX=2.0 .
Where I changed the two 2.0 variables in the examples to 2.0 2.1 3.0 3.5, and no luck

Compiled with 5 just fine for me using cmake-gui. Compiling CUDA for a single version is MUCH FASTER.

@jamesapollo2016

  1. Thats is a cmake file that detects CUDA. CUDA is indeed detected. That is not the issue.
  2. That cmake file is not self-explanatory. It does not relate to the memcpy error in a way I can understand. The cmake command works, its the make that fails.

I tried addin 50. I get the exact memcpy error. It might not even be in
those variables.
On May 15, 2016 20:57, «Philip» [email protected] wrote:

Philip’s message seems to be deleted, its available here:

 @guysoft <https://github.com/guysoft> to your question what exactly you
> have to insert here
>
> -DCUDA_ARCH_PTX=xx
> -DCUDA_ARCH_BIN=xx
>
> you can insert 50 for compute capability 5.0 in both options. The defaults
> 20 21 30 and 35 are for the versions 2.0,2.1,3.0 and 3.5 which are included
> in most the gpus where these lines were added
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly or view it on GitHub
> <https://github.com/Itseez/opencv/issues/6500#issuecomment-219300448>

since my assumption was wrong after testing this i deleted this again. Since you have to state the version with a dot.
cmake-gui output:

Commandline options:
-DCUDA_ARCH_BIN:STRING="5.0" -DCUDA_ARCH_PTX:STRING="5.0" 

Cache file:
CUDA_ARCH_BIN:STRING=5.0
CUDA_ARCH_PTX:STRING=5.0

so this wouldn’t change a thing. Seems to be different issue for you

So did you try already the option «5.0» since this has to be compatible with your 940M?

@Dikay900 I did it with the dots. I am using the commandline, this is my command:
cmake -DBUILD_opencv_legacy=OFF -DCUDA_ARCH_BIN=5.0 -DCUDA_ARCH_PTX=5.0 -DWITH_CUDA=ON .

can you try making a build folder for building the source and then build again using the commandline option my gui is stating? So something like this:

mkdir build
cd build
cmake -DBUILD_opencv_legacy=OFF -DCUDA_ARCH_BIN:STRING="5.0" -DCUDA_ARCH_PTX:STRING="5.0" -DWITH_CUDA=ON ..
make

@Dikay900 Does not work, get the same error. I should stress, opencv compiles fine if I do -DWITH_CUDA=ON. Its quite likely something to do with the CUDA settings/code.

I have tried it also on 3 clean installations with ubuntu 16.04 and the «nvidia-cuda-toolkit» isntalled from synaptic. All failed, are you all sure you have the same system?

@guysoft
as i write above a workaroud was to compile it with CUDA_HOST_COMPILER=clang-3.5 (you need to install the clang 3.5 first and if i remember right, you need to Disable the tests also)

@tommy87 It works if you disable the nvidia cuda with -DWITH_CUDA=OFF. But then you wont have GPU acceleration. Also you must make clean and delete all cache cmake files. After I extracted opencv I create a git repo and add all extracted files to it. That way I can do git clean -df and delete all the cmake files, they seem to remember settings otherwise.

The reason I don’t want to use clang is because I am using the OpenCV installtion to link against Caffe. Correct me if I am wrong, but using different compiles should result in a linking error.

Im Not sure if it leeds to a linking error… I want to used it also with Caffe, but i hadn’t the time to test it yet. But maybe i will try this today and than i can tell you if it works or not

@guysoft i have tried to compile caffe and i didnt get linking errors
So i have compiled openCV with CUDA and clang 3.5 and the NVIDIA version of caffe 0.15 with the cc compiler. To get the cc compiler running you need to follow this https://github.com/BVLC/caffe/issues/4046

@all
the solution for caffe is to add «set(CMAKE_CXX_FLAGS «${CMAKE_CXX_FLAGS} -D_FORCE_INLINES»)» to the CMakeList.txt i have tried it with opencv also but i was unable to find the right place to insert this. Maybe someone knows better where the line must be insert (if you tell me, i can try it by myself)

Simple replace in opencv/cmake/OpencvDetectCuda.cmake

  set(NVCC_FLAGS_EXTRA ${NVCC_FLAGS_EXTRA} -gencode arch=compute_${CMAKE_MATCH_2},code=sm_${CMAKE_MATCH_1})

to

  set(NVCC_FLAGS_EXTRA ${NVCC_FLAGS_EXTRA} -D_FORCE_INLINES -gencode arch=compute_${CMAKE_MATCH_2},code=sm_${CMAKE_MATCH_1})

it’s work for me!

@chapaev28 ‘s solution works. Added a pull request.

Понравилась статья? Поделить с друзьями:
  • Error mdl download
  • Error mbr2gpt can only be used from the windows preinstallation environment
  • Error maxtemp bed
  • Error maximum call stack size exceeded npm
  • Error max search depth too small