Compiling Caffe with Cuda 8.0 on GTX 1080 - caffe

I am using Nvidia GeForce GTX 1080, which requires Cuda 8.0. Nonetheless, from experiments, I find that it works well with Cuda 7.5 but the error appears when my network has a dropout layer. On the other hand, when I use Cuda 8.0, I get the error:
./build/tools/caffe: error while loading shared libraries: libcudart.so.7.5: cannot open shared object file: No such file or directory
I assume that the problem may be that I have compiled Caffe with Cuda 7.5 and the following CUDA_ARCH parameters.
CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
-gencode arch=compute_20,code=sm_21 \
-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_50,code=compute_50
When I use those parameters and try to compile with Cuda 8.0, I get the following error:
make: *** No rule to make target `/usr/local/cuda/include/thrust/detail/type_traits/result_of.h', needed by `.build_release/cuda/src/caffe/layers/softmax_layer.o'. Stop.
Do you think this is the problem? If yes, what would be the correct CUDA_ARCH parameters for Cuda 8.0 and GTX 1080. If no, what is the problem?

The solution is just:
make clean
make all
And I used the following CUDA_ARCH parameters:
CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
-gencode arch=compute_20,code=sm_21 \
-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_50,code=compute_50
-gencode=arch=compute_52,code=sm_52 \
-gencode=arch=compute_52,code=compute_52 \
-gencode=arch=compute_60,code=sm_60 \
-gencode=arch=compute_61,code=sm_61 \

You haven't included the correct NVIDIA nvcc sm flags to compile CUDA for the GTX1080 (SM architecture 61).
You should add -gencode=arch=compute_61,code=sm_61to your CUDA_ARCH parameter and recompile.

Related

Nvcc fatal : The version (‘40001’) of the host compiler (‘clang’) is not supported

I try to build one of the samples using
make -C 0_Simple/vectorAdd
I get the following output:
/Developer/NVIDIA/CUDA-9.0/bin/nvcc -ccbin clang++ -I…/…/common/inc -m64 -Xcompiler -arch -Xcompiler x86_64 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_60,code=compute_60 -o vectorAdd.o -c vectorAdd.cu
nvcc fatal : The version (‘40001’) of the host compiler (‘clang’) is not supported
make: *** [vectorAdd.o] Error 1
I have OSX 10.12.6 (sierra)
I installed XCode 8.3.3 and have set it using sudo xcode-select -s /Applications/Xcode_8.3.3.app/Contents/Developer.
I also installed the command line tools.
This is for CUDA-9.0 since any higher version requires OSX 10.13 or higher.
If I use:
sudo xcode-select --switch /Library/Developer/CommandLineTools/
and then:
make -C 0_Simple/vectorAdd
xcode-select: error: tool 'xcodebuild' requires Xcode, but active
developer directory '/Library/Developer/CommandLineTools' is a command
line tools instance expr: syntax error
/Developer/NVIDIA/CUDA-9.0/bin/nvcc -ccbin g++ -I../../common/inc
-m64 -Xcompiler -arch -Xcompiler x86_64 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35
-gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52
-gencode arch=compute_60,code=sm_60 -gencode arch=compute_60,code=compute_60 -o vectorAdd.o -c vectorAdd.cu nvcc
fatal : The version ('90000') of the host compiler ('Apple clang')
is not supported make: *** [vectorAdd.o] Error 1
It is all so unclear, why is it not supported, is it too new? Is it too old?
Should clang be updated or downgraded etc?
In general, CUDA is strictly versioned and requires exact versions of host SDKs and compilers to work. For CUDA 9.0 on OS X, the requirements are
XCode 8.3.3
Clang (Apple LLVM 8.1.0), aka "8100"
(Taken directly from the installation instructions)
If and only if you have those two items correctly installed, CUDA 9.0 will work on Mac OS X 10.12. Otherwise it will not.

Make Error 127 -( obj/convolutioanl_kernels.o) while compiling Yolo (Darknet) with GPU=1

System Configuration: Ubuntu 16.04, Nvidia GTX 1060
Cuda Tool Kit: 9.0
I installed Cuda 9.0 on my system and am able to output nvidia-smi
However, when I am trying to make darknet with GPU I am getting the following error:
nvcc -gencode arch=compute_30,code=sm_30 -gencode
arch=compute_35,code=sm_35 -gencode
arch=compute_50,code=[sm_50,compute_50] -gencode
arch=compute_52,code=[sm_52,compute_52] -gencode
arch=compute_61,code=[sm_61,compute_61] -DGPU
-I/usr/local/cuda/include/ --compiler-options "-Wall -Wfatal-errors -Wno-unused-result -Wno-unknown-pragmas -Ofast -DGPU" -c ./src/convolutional_kernels.cu -o obj/convolutional_kernels.o /bin/sh:
nvcc: command not found make: *** [obj/convolutional_kernels.o] Error
127
I had the same error and found out that the cuda path was not correctly added.
These are some post installation steps necessary after CUDA installation.
You might as well add them to your ~/.bashrc file.
$ export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
$ export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Post Installation Steps
its fixed for me thx.
export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
i am using cuda 10.1 version and this also working for that version.
It also worked for me thanks.
export PATH=/usr/local/cuda-11.5/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.5/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
I am using cuda 11.5 version so I just changed it.

"make" command is using wrong clang compiler (to compile CUDA samples) - how to fix this?

I am on MacOS Sierra 10.12.4 and trying to make CUDA 8.0 work on my MacBook Pro (Late 2013) with the CUDA compatible NVIDIA GeForce GT 750M.
I followed the NVIDIA installation guide and installed Xcode 8.2 and the corresponding command line tools, but when I try to compile the samples I get the following error:
$ make -C 1_Utilities/deviceQuery
/Developer/NVIDIA/CUDA-8.0/bin/nvcc -ccbin clang++ -I../../common/inc -m64 -Xcompiler -arch -Xcompiler x86_64 -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_60,code=compute_60 -o deviceQuery.o -c deviceQuery.cpp
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
nvcc fatal : The version ('30900') of the host compiler ('clang') is not supported
make: *** [deviceQuery.o] Error 1
Here is I think what the problem is:
the "make" command is using the wrong clang, but I don't know how to change/fix this.
Here you can see the two versions of clang, that are on my machine:
$ clang --version
clang version 3.9.0 (tags/RELEASE_390/final)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-3.9/bin
$ /usr/bin/clang --version
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: /Applications/Xcode_8.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
How can I make the "make" command use the correct clang version in the folder /usr/bin/clang by default?
Or is there a way to tell the "make" command to use the clang version in the folder /usr/bin/clang explicitly by adding some parameters/tags?
Here is also how my ~/.bash_profile looks like if that helps:
# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
# MacPorts Installer addition on 2016-09-26_at_12:06:30: adding an appropriate PATH variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
# Finished adapting your PATH environment variable for use with MacPorts.
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
# colorful terminal
export PS1="\[\033[36m\]\u\[\033[m\]#\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GFh'
# CUDA
export PATH=/Developer/NVIDIA/CUDA-8.0.61/bin${PATH:+:${PATH}}
export DYLD_LIBRARY_PATH=/Developer/NVIDIA/CUDA-8.0.61/lib\
${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}
By make -n as a dry run, you can see the real command behind make. Since I don't have a nvidia based mac, I'll show you the linux version as an example:
"/usr/local/cuda-8.0"/bin/nvcc -ccbin g++ -I../../common/inc -m64 -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_60,code=compute_60 -o deviceQuery.o -c deviceQuery.cpp
"/usr/local/cuda-8.0"/bin/nvcc -ccbin g++ -m64 -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_60,code=compute_60 -o deviceQuery deviceQuery.o
mkdir -p ../../bin/x86_64/linux/release
cp deviceQuery ../../bin/x86_64/linux/release
You can see that -ccbin (or --compiler-bindir) is the actual argument to set host compiler. Also nvcc --help will tell you about this argument.
Then you can either run nvcc manually or try to make some changes in the Makefile.
If changing the Makefile, you can easily find there is a HOST_COMPILER variable to set. And the darwin version part is like this:
ifeq ($(TARGET_OS),darwin)
ifeq ($(shell expr `xcodebuild -version | grep -i xcode | awk '{print $$2}' | cut -d'.' -f1` \>= 5),1)
HOST_COMPILER ?= clang++
endif
I guess you can just change it to your own clang path.

nvcc fatal: A single input file is required for a non-link phase when an outputfile is specified

I'm getting this problem with Nsight Eclipse. I just installed my Cuda Toolkit 5.0 I have a project which uses several C files and one Cuda file.
I read that sometimes the problem arises when you use C files along Cuda files in Nsight so I changed all files to .cu and .cuh extensions in my project. Likewise it said that sometimes the problem comes from having a path for the files with black spaces which I made sure it's not this case.
The error arises when it tries compiling the first file Calcular.cu
This is the compilation output
make all
Building file: ../Calcular.cu
Invoking: NVCC Compiler
nvcc -I/usr/include/ImageMagick -G -g -O0 -gencode arch=compute_11,code=sm_11 -gencode arch=compute_12,code=sm_12 -gencode arch=compute_13,code=sm_13 -gencode arch=compute_20,code=sm_20 -gencode arch=compute_20,code=sm_21 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -odir "" -M -o "Calcular.d" "../Calcular.cu"
nvcc –Xcompiler –fopenmp --compile -G -I/usr/include/ImageMagick -O0 -g -gencode arch=compute_11,code=compute_11 -gencode arch=compute_11,code=sm_11 -gencode arch=compute_12,code=compute_12 -gencode arch=compute_12,code=sm_12 -gencode arch=compute_13,code=compute_13 -gencode arch=compute_13,code=sm_13 -gencode arch=compute_20,code=compute_20 -gencode arch=compute_20,code=sm_20 -gencode arch=compute_20,code=sm_21 -gencode arch=compute_30,code=compute_30 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=compute_35 -gencode arch=compute_35,code=sm_35 -x cu -o "Calcular.o" "../Calcular.cu"
nvcc fatal : A single input file is required for a non-link phase when an outputfile is specified
make: *** [Calcular.o] Error 255
This are my compile options
–Xcompiler –fopenmp -I/usr/include/ImageMagick -G -g -O0
The compilation gives no other errors within the files. The files it needs to compile are Calcular.cu, Calcular.cuh, Preprocesamiento.cu, Preprocesamiento.cuh, Principal.cu, Principal.cuh.
Do someone knows how to fix this? Thanks
The dashes you have here:
–Xcompiler –fopenmp
Are not the right kind of dashes. If you look closely at your question posting, you will see they are a slightly different character than the correct one which precedes this:
-I/usr/include/ImageMagick
for example.
You need to replace those dashes with the same kind of dash used in front of the include switch. If you manually entered those compiler options, you need to fix those characters.
This dash:
–
is not correct.
Use this dash:
-
instead.

CUDA linkage error

These commands were generated procedurally by a Makefile that I essentially copied from NVIDIA's tutorial pages; it's over 100 lines long and will post it if you think it's necessary, but these commands are sufficient to reproduce the errors.
g++ -m64 -I/usr/local/cuda/include -I. -I.. -I../../common/inc -I/usr/local/cuda/lib64 -o shallowwater.o -c shallowwater.cpp
/usr/local/cuda/bin/nvcc -m64 -gencode arch=compute_10,code=sm_10 -gencode arch=compute_20,code=sm_20 -I/usr/local/cuda/include -I. -I.. -I../../common/inc -I/usr/local/cuda/lib64 -o shallowwatercudamain.o -c shallowwatercudamain.cu
g++ -m64 -o shallowwater shallowwater.o shallowwatercudamain.o -L -lcudart
The first two work; there is no compile error for either of the two source files, but when the third command is run, I get the following error:
shallowwatercudamain.o: In function `__cudaUnregisterBinaryUtil()':
tmpxft_00004e70_00000000-4_shallowwatercudamain.compute_20.cudafe1.cpp:(.text+0x36): undefined reference to `__cudaUnregisterFatBinary'
shallowwatercudamain.o: In function `__sti____cudaRegisterAll_66_tmpxft_00004e70_00000000_6_shallowwatercudamain_compute_20_cpp1_ii_runIt()':
tmpxft_00004e70_00000000-4_shallowwatercudamain.compute_20.cudafe1.cpp:(.text+0x46): undefined reference to `__cudaRegisterFatBinary'
collect2: ld returned 1 exit status
make: *** [shallowwater] Error 1
Here is some relevant system information:
[foo#bar code]$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2012 NVIDIA Corporation
Built on Thu_Apr__5_00:24:31_PDT_2012
Cuda compilation tools, release 4.2, V0.2.1221
[foo#bar code]$ uname -a
Linux intel19 2.6.32-71.el6.x86_64 #1 SMP Wed Sep 1 01:33:01 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
I found someone with a similar error here, seen here: /usr/bin/ld: cannot find -lcudart
I'm embarrassed to say I found this, made the same change except for g++ instead of gfortran, and it worked. Afterwards, I tried it again and it did not work. I get the same error with:
g++ -m64 -o shallowwater shallowwater.o shallowwatercudamain.o -L -L/usr/local/cuda/lib64
This command does not look right to me:
g++ -m64 -o shallowwater shallowwater.o shallowwatercudamain.o -L -lcudart
And this command does not look right to me:
g++ -m64 -o shallowwater shallowwater.o shallowwatercudamain.o -L -L/usr/local/cuda/lib64
This command looks right to me:
g++ -m64 -o shallowwater shallowwater.o shallowwatercudamain.o -L/usr/local/cuda/lib64 -lcudart
You need to tell g++ where to look for the cudart library, that is what the -L/usr/local/cuda/lib64 switch is for (so it needs a path, you cannot just use -L by itself) and you need to tell g++ the name of the library to use, that is what the -lcudart is for.
I realized you didnt put "-lcudart" in your last line. Did you link to cudart when you were doing actual compilation ?