运行 Cuda 9.0 的 Ubuntu 16.04 上编译错误

运行 Cuda 9.0 的 Ubuntu 16.04 上编译错误

我正在尝试设置一个依赖于 Cuda 的应用程序 - 我正在运行带有 Cuda 9.0 和 384 Nvidia 驱动程序 + GCC 5.4 的 Ubuntu 16.04 - 详情如下。

库达:

$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Sep__1_21:08:03_CDT_2017
Cuda compilation tools, release 9.0, V9.0.176

英伟达:

$ nvidia-smi
Fri Oct 27 00:34:35 2017       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 384.90                 Driver Version: 384.90                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 960     Off  | 00000000:02:00.0 Off |                  N/A |
|  0%   31C    P0    27W / 120W |      0MiB /  1989MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

工具包中的 Cuda 示例可以正常构建和运行,因此我相信问题不在于 Cuda 或 Nvidia 部分:)

海湾合作委员会(GCC):

$ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.5) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Cuda 显然对其使用的 GCC 版本非常挑剔,但有人告诉我(谷歌搜索)这是正确的版本(?)

我查阅过的有关构建的其他参考资料来自项目所有者:

在我按照说明运行 ./build.sh 脚本之前,我没有遇到任何问题。

我收到的错误是:

Makefile:2199: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/tony/Mining/ccminer1'
Makefile:654: recipe for target 'all' failed
make: *** [all] Error 2

完整输出:

$ ./build.sh
Making distclean in compat
make[1]: Entering directory '/home/tony/Mining/ccminer1/compat'
Making distclean in jansson
make[2]: Entering directory '/home/tony/Mining/ccminer1/compat/jansson'
test -z "libjansson.a" || rm -f libjansson.a
rm -f *.o
rm -f *.tab.c
test -z "" || rm -f 
test . = "." || test -z "" || rm -f 
rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
rm -rf ./.deps
rm -f Makefile
make[2]: Leaving directory '/home/tony/Mining/ccminer1/compat/jansson'
make[2]: Entering directory '/home/tony/Mining/ccminer1/compat'
test -z "" || rm -f 
test . = "." || test -z "" || rm -f 
rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
make[2]: Leaving directory '/home/tony/Mining/ccminer1/compat'
rm -f Makefile
make[1]: Leaving directory '/home/tony/Mining/ccminer1/compat'
make[1]: Entering directory '/home/tony/Mining/ccminer1'
test -z "ccminer" || rm -f ccminer
rm -f *.o
rm -f Algo256/*.o
rm -f JHA/*.o
rm -f compat/*.o
rm -f crypto/*.o
rm -f crypto/cpu/*.o
rm -f equi/*.o
rm -f equi/blake2/*.o
rm -f heavy/*.o
rm -f lbry/*.o
rm -f lyra2/*.o
rm -f neoscrypt/*.o
rm -f quark/*.o
rm -f qubit/*.o
rm -f scrypt/*.o
rm -f sha256/*.o
rm -f sia/*.o
rm -f skunk/*.o
rm -f sph/*.o
rm -f tribus/*.o
rm -f x11/*.o
rm -f x13/*.o
rm -f x15/*.o
rm -f x17/*.o
rm -f *.tab.c
test -z "" || rm -f 
test . = "." || test -z "" || rm -f 
rm -f Algo256/.deps/.dirstamp
rm -f Algo256/.dirstamp
rm -f JHA/.deps/.dirstamp
rm -f JHA/.dirstamp
rm -f compat/.deps/.dirstamp
rm -f compat/.dirstamp
rm -f crypto/.deps/.dirstamp
rm -f crypto/.dirstamp
rm -f crypto/cpu/.deps/.dirstamp
rm -f crypto/cpu/.dirstamp
rm -f equi/.deps/.dirstamp
rm -f equi/.dirstamp
rm -f equi/blake2/.deps/.dirstamp
rm -f equi/blake2/.dirstamp
rm -f heavy/.deps/.dirstamp
rm -f heavy/.dirstamp
rm -f lbry/.deps/.dirstamp
rm -f lbry/.dirstamp
rm -f lyra2/.deps/.dirstamp
rm -f lyra2/.dirstamp
rm -f neoscrypt/.deps/.dirstamp
rm -f neoscrypt/.dirstamp
rm -f quark/.deps/.dirstamp
rm -f quark/.dirstamp
rm -f qubit/.deps/.dirstamp
rm -f qubit/.dirstamp
rm -f scrypt/.deps/.dirstamp
rm -f scrypt/.dirstamp
rm -f sha256/.deps/.dirstamp
rm -f sha256/.dirstamp
rm -f sia/.deps/.dirstamp
rm -f sia/.dirstamp
rm -f skunk/.deps/.dirstamp
rm -f skunk/.dirstamp
rm -f sph/.deps/.dirstamp
rm -f sph/.dirstamp
rm -f tribus/.deps/.dirstamp
rm -f tribus/.dirstamp
rm -f x11/.deps/.dirstamp
rm -f x11/.dirstamp
rm -f x13/.deps/.dirstamp
rm -f x13/.dirstamp
rm -f x15/.deps/.dirstamp
rm -f x15/.dirstamp
rm -f x17/.deps/.dirstamp
rm -f x17/.dirstamp
rm -f ccminer-config.h stamp-h1
rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
rm -f cscope.out cscope.in.out cscope.po.out cscope.files
make[1]: Leaving directory '/home/tony/Mining/ccminer1'
rm -f config.status config.cache config.log configure.lineno config.status.lineno
rm -rf ./.deps compat/.deps crypto/.deps crypto/cpu/.deps equi/.deps equi/blake2/.deps lyra2/.deps neoscrypt/.deps sia/.deps sph/.deps x13/.deps
rm -f Makefile
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for gcc option to accept ISO C99... none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking whether gcc needs -traditional... no
checking dependency style of gcc... gcc3
checking for ranlib... ranlib
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking for gcc option to support OpenMP... -fopenmp
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking sys/endian.h usability... no
checking sys/endian.h presence... no
checking for sys/endian.h... no
checking sys/param.h usability... yes
checking sys/param.h presence... yes
checking for sys/param.h... yes
checking syslog.h usability... yes
checking syslog.h presence... yes
checking for syslog.h... yes
checking for sys/sysctl.h... yes
checking whether be32dec is declared... no
checking whether le32dec is declared... no
checking whether be32enc is declared... no
checking whether le32enc is declared... no
checking for size_t... yes
checking for working alloca.h... yes
checking for alloca... yes
checking for getopt_long... yes
checking for json_loads in -ljansson... yes
checking for pthread_create in -lpthread... yes
checking for gzopen in -lz... yes
checking for SSL_library_init in -lssl... yes
checking for EVP_DigestFinal_ex in -lcrypto... yes
checking for gawk... (cached) mawk
checking for curl-config... /usr/bin/curl-config
checking for the version of libcurl... 7.47.0
checking for libcurl >= version 7.15.2... yes
checking whether libcurl is usable... yes
checking for curl_free... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating compat/Makefile
config.status: creating compat/jansson/Makefile
config.status: creating ccminer-config.h
config.status: executing depfiles commands
make  all-recursive
make[1]: Entering directory '/home/tony/Mining/ccminer1'
Making all in compat
make[2]: Entering directory '/home/tony/Mining/ccminer1/compat'
make[3]: Entering directory '/home/tony/Mining/ccminer1/compat'
make[3]: Nothing to be done for 'all-am'.
make[3]: Leaving directory '/home/tony/Mining/ccminer1/compat'
make[2]: Leaving directory '/home/tony/Mining/ccminer1/compat'
make[2]: Entering directory '/home/tony/Mining/ccminer1'
gcc -DHAVE_CONFIG_H -I.  -fopenmp  -pthread -fno-strict-aliasing  -I/usr/local/cuda/include -DUSE_WRAPNVML    -g -O2 -MT ccminer-crc32.o -MD -MP -MF .deps/ccminer-crc32.Tpo -c -o ccminer-crc32.o `test -f 'crc32.c' || echo './'`crc32.c
gcc -DHAVE_CONFIG_H -I.  -fopenmp  -pthread -fno-strict-aliasing  -I/usr/local/cuda/include -DUSE_WRAPNVML    -g -O2 -MT ccminer-hefty1.o -MD -MP -MF .deps/ccminer-hefty1.Tpo -c -o ccminer-hefty1.o `test -f 'hefty1.c' || echo './'`hefty1.c
g++ -DHAVE_CONFIG_H -I.  -fopenmp  -pthread -fno-strict-aliasing  -I/usr/local/cuda/include -DUSE_WRAPNVML    -O3 -march=native -D_REENTRANT -falign-functions=16 -falign-jumps=16 -falign-labels=16 -MT ccminer-ccminer.o -MD -MP -MF .deps/ccminer-ccminer.Tpo -c -o ccminer-ccminer.o `test -f 'ccminer.cpp' || echo './'`ccminer.cpp
g++ -DHAVE_CONFIG_H -I.  -fopenmp  -pthread -fno-strict-aliasing  -I/usr/local/cuda/include -DUSE_WRAPNVML    -O3 -march=native -D_REENTRANT -falign-functions=16 -falign-jumps=16 -falign-labels=16 -MT ccminer-pools.o -MD -MP -MF .deps/ccminer-pools.Tpo -c -o ccminer-pools.o `test -f 'pools.cpp' || echo './'`pools.cpp
mv -f .deps/ccminer-crc32.Tpo .deps/ccminer-crc32.Po
g++ -DHAVE_CONFIG_H -I.  -fopenmp  -pthread -fno-strict-aliasing  -I/usr/local/cuda/include -DUSE_WRAPNVML    -O3 -march=native -D_REENTRANT -falign-functions=16 -falign-jumps=16 -falign-labels=16 -MT ccminer-util.o -MD -MP -MF .deps/ccminer-util.Tpo -c -o ccminer-util.o `test -f 'util.cpp' || echo './'`util.cpp
mv -f .deps/ccminer-pools.Tpo .deps/ccminer-pools.Po
g++ -DHAVE_CONFIG_H -I.  -fopenmp  -pthread -fno-strict-aliasing  -I/usr/local/cuda/include -DUSE_WRAPNVML    -O3 -march=native -D_REENTRANT -falign-functions=16 -falign-jumps=16 -falign-labels=16 -MT ccminer-bench.o -MD -MP -MF .deps/ccminer-bench.Tpo -c -o ccminer-bench.o `test -f 'bench.cpp' || echo './'`bench.cpp
mv -f .deps/ccminer-hefty1.Tpo .deps/ccminer-hefty1.Po
g++ -DHAVE_CONFIG_H -I.  -fopenmp  -pthread -fno-strict-aliasing  -I/usr/local/cuda/include -DUSE_WRAPNVML    -O3 -march=native -D_REENTRANT -falign-functions=16 -falign-jumps=16 -falign-labels=16 -MT ccminer-bignum.o -MD -MP -MF .deps/ccminer-bignum.Tpo -c -o ccminer-bignum.o `test -f 'bignum.cpp' || echo './'`bignum.cpp
mv -f .deps/ccminer-bench.Tpo .deps/ccminer-bench.Po
g++ -DHAVE_CONFIG_H -I.  -fopenmp  -pthread -fno-strict-aliasing  -I/usr/local/cuda/include -DUSE_WRAPNVML    -O3 -march=native -D_REENTRANT -falign-functions=16 -falign-jumps=16 -falign-labels=16 -MT ccminer-api.o -MD -MP -MF .deps/ccminer-api.Tpo -c -o ccminer-api.o `test -f 'api.cpp' || echo './'`api.cpp
mv -f .deps/ccminer-bignum.Tpo .deps/ccminer-bignum.Po
g++ -DHAVE_CONFIG_H -I.  -fopenmp  -pthread -fno-strict-aliasing  -I/usr/local/cuda/include -DUSE_WRAPNVML    -O3 -march=native -D_REENTRANT -falign-functions=16 -falign-jumps=16 -falign-labels=16 -MT ccminer-hashlog.o -MD -MP -MF .deps/ccminer-hashlog.Tpo -c -o ccminer-hashlog.o `test -f 'hashlog.cpp' || echo './'`hashlog.cpp
mv -f .deps/ccminer-api.Tpo .deps/ccminer-api.Po
g++ -DHAVE_CONFIG_H -I.  -fopenmp  -pthread -fno-strict-aliasing  -I/usr/local/cuda/include -DUSE_WRAPNVML    -O3 -march=native -D_REENTRANT -falign-functions=16 -falign-jumps=16 -falign-labels=16 -MT ccminer-nvml.o -MD -MP -MF .deps/ccminer-nvml.Tpo -c -o ccminer-nvml.o `test -f 'nvml.cpp' || echo './'`nvml.cpp
mv -f .deps/ccminer-util.Tpo .deps/ccminer-util.Po
g++ -DHAVE_CONFIG_H -I.  -fopenmp  -pthread -fno-strict-aliasing  -I/usr/local/cuda/include -DUSE_WRAPNVML    -O3 -march=native -D_REENTRANT -falign-functions=16 -falign-jumps=16 -falign-labels=16 -MT ccminer-stats.o -MD -MP -MF .deps/ccminer-stats.Tpo -c -o ccminer-stats.o `test -f 'stats.cpp' || echo './'`stats.cpp
mv -f .deps/ccminer-hashlog.Tpo .deps/ccminer-hashlog.Po
g++ -DHAVE_CONFIG_H -I.  -fopenmp  -pthread -fno-strict-aliasing  -I/usr/local/cuda/include -DUSE_WRAPNVML    -O3 -march=native -D_REENTRANT -falign-functions=16 -falign-jumps=16 -falign-labels=16 -MT ccminer-sysinfos.o -MD -MP -MF .deps/ccminer-sysinfos.Tpo -c -o ccminer-sysinfos.o `test -f 'sysinfos.cpp' || echo './'`sysinfos.cpp
mv -f .deps/ccminer-sysinfos.Tpo .deps/ccminer-sysinfos.Po
g++ -DHAVE_CONFIG_H -I.  -fopenmp  -pthread -fno-strict-aliasing  -I/usr/local/cuda/include -DUSE_WRAPNVML    -O3 -march=native -D_REENTRANT -falign-functions=16 -falign-jumps=16 -falign-labels=16 -MT ccminer-cuda.o -MD -MP -MF .deps/ccminer-cuda.Tpo -c -o ccminer-cuda.o `test -f 'cuda.cpp' || echo './'`cuda.cpp
mv -f .deps/ccminer-stats.Tpo .deps/ccminer-stats.Po
g++ -DHAVE_CONFIG_H -I.  -fopenmp  -pthread -fno-strict-aliasing  -I/usr/local/cuda/include -DUSE_WRAPNVML    -O3 -march=native -D_REENTRANT -falign-functions=16 -falign-jumps=16 -falign-labels=16 -MT ccminer-nvsettings.o -MD -MP -MF .deps/ccminer-nvsettings.Tpo -c -o ccminer-nvsettings.o `test -f 'nvsettings.cpp' || echo './'`nvsettings.cpp
mv -f .deps/ccminer-nvml.Tpo .deps/ccminer-nvml.Po
g++ -DHAVE_CONFIG_H -I.  -fopenmp  -pthread -fno-strict-aliasing  -I/usr/local/cuda/include -DUSE_WRAPNVML    -O3 -march=native -D_REENTRANT -falign-functions=16 -falign-jumps=16 -falign-labels=16 -MT equi/ccminer-equihash.o -MD -MP -MF equi/.deps/ccminer-equihash.Tpo -c -o equi/ccminer-equihash.o `test -f 'equi/equihash.cpp' || echo './'`equi/equihash.cpp
mv -f .deps/ccminer-nvsettings.Tpo .deps/ccminer-nvsettings.Po
/usr/local/cuda/bin/nvcc -gencode=arch=compute_52,code="sm_52,compute_52" -I/usr/local/cuda/include -I. -O3 -lineno -Xcompiler -Wall  -D_FORCE_INLINES  --ptxas-options="-v" --maxrregcount=128 -o equi/cuda_equi.o -c equi/cuda_equi.cu
nvcc fatal   : 'compute_52' is not in 'keyword=value' format
Makefile:2667: recipe for target 'equi/cuda_equi.o' failed
make[2]: *** [equi/cuda_equi.o] Error 1
make[2]: *** Waiting for unfinished jobs....
mv -f .deps/ccminer-cuda.Tpo .deps/ccminer-cuda.Po
mv -f .deps/ccminer-ccminer.Tpo .deps/ccminer-ccminer.Po
mv -f equi/.deps/ccminer-equihash.Tpo equi/.deps/ccminer-equihash.Po
make[2]: Leaving directory '/home/tony/Mining/ccminer1'
Makefile:2199: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/tony/Mining/ccminer1'
Makefile:654: recipe for target 'all' failed
make: *** [all] Error 2

提前致谢!

(编辑以添加完整的构建输出)

答案1

不确定您是否知道问题出在哪里,但我刚刚构建了 ccminer,并浏览了一些教程,还发现了您的帖子。

您的日志中有一行是罪魁祸首:

/usr/local/cuda/bin/nvcc -gencode=arch=compute_52,code="sm_52,compute_52" -I/usr/local/cuda/include -I. -O3 -lineno -Xcompiler -Wall  -D_FORCE_INLINES  --ptxas-options="-v" --maxrregcount=128 -o equi/cuda_equi.o -c equi/cuda_equi.cu

我的日志中也有类似的行:

/usr/local/cuda/bin/nvcc -gencode=arch=compute_61,code=\"sm_61,compute_61\" -I/usr/local/cuda/include -I. -O3 -lineno -Xcompiler -Wall  -D_FORCE_INLINES  --ptxas-options="-v" --maxrregcount=128 -o scrypt/sha256.o -c scrypt/sha256.cu

现在您可以看到这里的区别,您在 Makefile.am 中缺少 nvcc_ARCH 的反斜杠:

nvcc_ARCH  = -gencode=arch=compute_52,code=\"sm_52,compute_52\"

我希望有人会发现它有用。

相关内容