fireice-uk / xmr-stak-nvidia

Monero NVIDIA miner
GNU General Public License v3.0
248 stars 98 forks source link

Is it possible to compile with CUDA 7.5? #20

Open George-Gate opened 7 years ago

George-Gate commented 7 years ago

Hi~ My server only has CUDA Toolkit 7.5. If I compile xmr-stak-nvidia with CUDA 8.0 on another machine and run the binary on the server, it gives an error:

./xmr-stak-nvidia: error while loading shared libraries: libcudart.so.8.0: cannot open shared object file: No such file or directory

And if I change the version of CUDA on the compiling machine from 8.0 to 7.5 (keep other things the same), I get errors from make:

[ 11%] [ 11%] Building NVCC (Device) object CMakeFiles/cuda_code.dir/nvcc_code/./cuda_code_generated_cuda_core.cu.o Building NVCC (Device) object CMakeFiles/cuda_code.dir/nvcc_code/./cuda_code_generated_cuda_extra.cu.o CMake Error at cuda_code_generated_cuda_extra.cu.o.cmake:206 (message): Error generating /home/george/Documents/xmr-stak-nvidia-1.0.1/CMakeFiles/cuda_code.dir/nvcc_code/./cuda_code_generated_cuda_extra.cu.o

CMake Error at cuda_code_generated_cuda_core.cu.o.cmake:206 (message): Error generating /home/george/Documents/xmr-stak-nvidia-1.0.1/CMakeFiles/cuda_code.dir/nvcc_code/./cuda_code_generated_cuda_core.cu.o

make[2]: [CMakeFiles/cuda_code.dir/nvcc_code/./cuda_code_generated_cuda_extra.cu.o] Error 1 make[2]: Waiting for unfinished jobs.... make[2]: [CMakeFiles/cuda_code.dir/nvcc_code/./cuda_code_generated_cuda_core.cu.o] Error 1 make[1]: [CMakeFiles/cuda_code.dir/all] Error 2 make: *** [all] Error 2

How to solve this problem?

psychocrypt commented 7 years ago

Yes it is possible. Cuda 7.5 is supported. You can't compile a CUDA code with a newer version and run it on a older driver but you can compile it on 7.5 and run it on a system with a newer driver e.g. 8.0.

If possible you should use the newest CUDA version because the compiler in CUDA 8 is much better than the older one.

George-Gate commented 7 years ago

The problem is I got errors when compiling with CUDA 7.5.

George-Gate commented 7 years ago

I try again and this time get more detailed error info:

[ 11%] [ 11%] Building NVCC (Device) object CMakeFiles/cuda_code.dir/nvcc_code/./cuda_code_generated_cuda_core.cu.o Building NVCC (Device) object CMakeFiles/cuda_code.dir/nvcc_code/./cuda_code_generated_cuda_extra.cu.o In file included from /usr/local/cuda-7.5/include/cuda_runtime.h:76:0, from :0: /usr/local/cuda-7.5/include/host_config.h:115:2: error: #error -- unsupported GNU version! gcc versions later than 4.9 are not supported!

error -- unsupported GNU version! gcc versions later than 4.9 are not supported!

^ In file included from /usr/local/cuda-7.5/include/cuda_runtime.h:76:0, from :0: /usr/local/cuda-7.5/include/host_config.h:115:2: error: #error -- unsupported GNU version! gcc versions later than 4.9 are not supported!

error -- unsupported GNU version! gcc versions later than 4.9 are not supported!

^ CMake Error at cuda_code_generated_cuda_core.cu.o.cmake:206 (message): Error generating /home/george/Documents/xmr-stak-nvidia-1.0.1/CMakeFiles/cuda_code.dir/nvcc_code/./cuda_code_generated_cuda_core.cu.o

make[2]: [CMakeFiles/cuda_code.dir/nvcc_code/./cuda_code_generated_cuda_core.cu.o] Error 1 make[2]: Waiting for unfinished jobs.... CMake Error at cuda_code_generated_cuda_extra.cu.o.cmake:206 (message): Error generating /home/george/Documents/xmr-stak-nvidia-1.0.1/CMakeFiles/cuda_code.dir/nvcc_code/./cuda_code_generated_cuda_extra.cu.o

make[2]: [CMakeFiles/cuda_code.dir/nvcc_code/./cuda_code_generated_cuda_extra.cu.o] Error 1 make[1]: [CMakeFiles/cuda_code.dir/all] Error 2 make: *** [all] Error 2

It seems that CUDA 7.5 do not support gcc later than 4.9. But the GCC version must be at least 5.1 according to MakeList.txt ......

George-Gate commented 7 years ago

Did anyone succeed in compiling with CUDA 7.5?

psychocrypt commented 7 years ago

Ahh yes you are right CUDA 7.5 only supports GCC <= 4.9. xmr-stak needs at least GCC 5.1. Please try to compile with clang, please read this guide.

George-Gate commented 7 years ago

It's possible to compile with gcc-5. Line 133 of file /usr/local/cuda-7.5/include/host_config.h:

if GNUC > 4 || (GNUC == 4 && __GNUC_MINOR__ > 9)

This line provides a version check of GCC. Just change this line to avoid the error and the compilation will succeed. The program can run on my server now.

But...... new problem: I'm so surprised that a Kepler GK210 GPU gives only about 220 H/s ...... This GPU has 15 SMX, 2496 cores, and 12GB GDDR5 memory. But when I set parameters like (threads x blocks) = 256x15 or 128x30, the program return errors....... Below is a list of errors:

(threads x blocks)                  Result
----------------------------------------------------------------------------
256x15                     GPU 0: invalid configuration argument
128x30                     GPU 0: an illegal memory access was encountered
128x15                     No errors, GPU ultilization=99%, but hashrate=0 for at least 10 min.
64x30                      hashrate~30H/s
64x15                      hashrate~130H/s
32x15                      hashrate~120H/s
32x30                      hashrate~217.9H/s
32x45                      hashrate~80H/s
psychocrypt commented 7 years ago

What is the correct type of the gpu? k40? I checked the cmake file from the master branch, there is no flag set to compile for sm_35. You could add the architecture to CUDA_CXX_FLAGS but the easiest way is to use our dev branch. We will release the dev branch asap.

George-Gate commented 7 years ago

It's Tesla K80, 2 Kepler GK210 GPU per card. It's compute capability is 3.7.

psychocrypt commented 7 years ago

Please check your blocks in the config because k80 has 13 SMX (multiprocessors)

George-Gate commented 7 years ago

Only 13 SMX? 13 SMX per card or 13 SMX per GPU? I will check it later.

psychocrypt commented 7 years ago

K80 has two sockets but it looks like 2 gpus. Try nvidia-smi to get an overview. Each socket has 13 SMX. The best config for k80 is threads =24 and blocks =39