fireice-uk / xmr-stak

Free Monero RandomX Miner and unified CryptoNight miner
GNU General Public License v3.0
4.06k stars 1.79k forks source link

Compiling for Nvidia fails on Ubuntu 17.04 #226

Closed pascalwacker closed 6 years ago

pascalwacker commented 6 years ago

My Laptop has a Nvidia Geforce 740M, which should support CUDA. The OS is Ubuntu 17.04.

I've followed the instructions on here: https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1704&target_type=deblocal

`sudo dpkg -i cuda-repo-ubuntu1704-9-0-local_9.0.176-1_amd64.deb`
`sudo apt-key add /var/cuda-repo-<version>/7fa2af80.pub`
`sudo apt-get update`
`sudo apt-get install cuda`

After that I tried to compile it using:

cmake .. -DCMAKE_LINK_STATIC=OFF -DCMAKE_BUILD_TYPE=Release -DMICROHTTPD_ENABLE=OFF -DXMR-STAK_CURRENCY=monero -DXMR-STAK_COMPILE=native -DCPU_ENABLE=ON -DHWLOC_ENABLE=ON -DCUDA_ENABLE=ON -DOpenCL_ENABLE=OFF
make -j

(I first tryed it with -DCMAKE_LINK_STATIC=ON but to minimize the things that could fail I set it to OFF) Which didn't work, as GCC isn't supportet in the installed version

I tried to set a specific version for CC and CXX:

export CC=/usr/bin/clang-3.8
export CXX=/usr/bin/clang++-3.8
cmake .. -DCMAKE_LINK_STATIC=OFF -DCMAKE_BUILD_TYPE=Release -DMICROHTTPD_ENABLE=OFF -DXMR-STAK_CURRENCY=monero -DXMR-STAK_COMPILE=native -DCPU_ENABLE=ON -DHWLOC_ENABLE=ON -DCUDA_ENABLE=ON -DOpenCL_ENABLE=OFF
make -j

This also failed with errors. Since the error log is pretty long, I posted it to https://pastebin.com/MmEAstG1

What options do I need to specify in order to enable the GPU mining? (Note: With the xmr-stack-nvidia it used to work for me, using said CC and CXX variables)

kth5 commented 6 years ago

I could compile with Cuda 9.0.176 and GCC 6.4.1 on Archlinux (via gcc6 package) and had no need to get Clang installed at all, no warnings whatsoever. I use this to build myself a package for all my rigs.

CC=gcc-6 CXX=g++-6 cmake . -DXMR-STAK_COMPILE=generic -DOpenCL_ENABLE=ON -DCUDA_ENABLE=ON

Might be worth trying to get GCC 6.4.x installed alongside the defaults on Ubuntu 17.04.

psychocrypt commented 6 years ago

The best is to use gcnu gcc 5.X and cuda9. I need to try clang again but you have used a very old clang version. I need to check if clang 4.x produce the same error.

pascalwacker commented 6 years ago

My Cuda version is 9.0.176, gcc and g++ are both at 6.3.0

I've tried the following:

export CC=gcc-6
export CXX=g++-6
cmake . -DCMAKE_LINK_STATIC=ON -DCMAKE_BUILD_TYPE=Release -DMICROHTTPD_ENABLE=OFF -DXMR-STAK_CURRENCY=monero -DXMR-STAK_COMPILE=native -DCPU_ENABLE=ON -DHWLOC_ENABLE=ON -DCUDA_ENABLE=ON -DOpenCL_ENABLE=OFF
make -j

which gives me this error (at the make step):

[ 86%] Building CXX object CMakeFiles/xmr-stak.dir/xmrstak/cli/cli-miner.cpp.o
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 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).
In file included from /usr/include/cuda_runtime.h:78:0,
                 from <command-line>:0:
/usr/include/host_config.h:119:2: error: #error -- unsupported GNU version! gcc versions later than 5 are not supported!
 #error -- unsupported GNU version! gcc versions later than 5 are not supported!
  ^~~~~
In file included from /usr/include/cuda_runtime.h:78:0,
                 from <command-line>:0:
/usr/include/host_config.h:119:2: error: #error -- unsupported GNU version! gcc versions later than 5 are not supported!
 #error -- unsupported GNU version! gcc versions later than 5 are not supported!
  ^~~~~
CMake Error at xmrstak_cuda_backend_generated_cuda_core.cu.o.Release.cmake:222 (message):
  Error generating
  /home/pascal/VM/b/m/xmr-stak/build-x86_64-linux-gnu/CMakeFiles/xmrstak_cuda_backend.dir/xmrstak/backend/nvidia/nvcc_code/./xmrstak_cuda_backend_generated_cuda_core.cu.o

CMakeFiles/xmrstak_cuda_backend.dir/build.make:63: recipe for target 'CMakeFiles/xmrstak_cuda_backend.dir/xmrstak/backend/nvidia/nvcc_code/xmrstak_cuda_backend_generated_cuda_core.cu.o' failed
make[2]: *** [CMakeFiles/xmrstak_cuda_backend.dir/xmrstak/backend/nvidia/nvcc_code/xmrstak_cuda_backend_generated_cuda_core.cu.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CMake Error at xmrstak_cuda_backend_generated_cuda_extra.cu.o.Release.cmake:222 (message):
  Error generating
  /home/pascal/VM/b/m/xmr-stak/build-x86_64-linux-gnu/CMakeFiles/xmrstak_cuda_backend.dir/xmrstak/backend/nvidia/nvcc_code/./xmrstak_cuda_backend_generated_cuda_extra.cu.o

CMakeFiles/xmrstak_cuda_backend.dir/build.make:70: recipe for target 'CMakeFiles/xmrstak_cuda_backend.dir/xmrstak/backend/nvidia/nvcc_code/xmrstak_cuda_backend_generated_cuda_extra.cu.o' failed
make[2]: *** [CMakeFiles/xmrstak_cuda_backend.dir/xmrstak/backend/nvidia/nvcc_code/xmrstak_cuda_backend_generated_cuda_extra.cu.o] Error 1
CMakeFiles/Makefile2:142: recipe for target 'CMakeFiles/xmrstak_cuda_backend.dir/all' failed
make[1]: *** [CMakeFiles/xmrstak_cuda_backend.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 90%] Linking CXX executable bin/xmr-stak

I then went on, as @kth5 suggested and installed gcc-6.4 (https://ftp.gnu.org/gnu/gcc/gcc-6.4.0/) but it failed. I'll try to look into it on the weekend again.

psychocrypt commented 6 years ago

Your installed cuda version is cuda8. Cuda8 is not compatible with gcc6. I can see from the errors that cuda9 ia not installed or installed but cuda8 is selected because the environment is configured to use cuda8.

pascalwacker commented 6 years ago

As @psychocrypt suggested, I also tryed with gcc-5:

export CC=gcc-5
export CXX=g++-5
cmake . -DCMAKE_LINK_STATIC=ON -DCMAKE_BUILD_TYPE=Release -DMICROHTTPD_ENABLE=OFF -DXMR-STAK_CURRENCY=monero -DXMR-STAK_COMPILE=native -DCPU_ENABLE=ON -DHWLOC_ENABLE=ON -DCUDA_ENABLE=ON -DOpenCL_ENABLE=OFF
make -j

Which resulted in a success

pascalwacker commented 6 years ago

@psychocrypt I thought, I should have Cuda 9: cat /usr/local/cuda/version.txt results in CUDA Version 9.0.176

psychocrypt commented 6 years ago

+1

pascalwacker commented 6 years ago

Hmm now I've got another issue, it seams that CUDO throws a runtime error:

[2017-11-24 17:25:15] : Start mining: MONERO
[2017-11-24 17:25:15] : Starting NVIDIA GPU thread 0, no affinity.
[2017-11-24 17:25:15] : MEMORY ALLOC FAILED: mmap failed
[2017-11-24 17:25:15] : Starting single thread, affinity: 0.
[2017-11-24 17:25:15] : hwloc: memory pinned
[2017-11-24 17:25:15] : Starting single thread, affinity: 1.
[2017-11-24 17:25:15] : MEMORY ALLOC FAILED: mmap failed
[2017-11-24 17:25:15] : hwloc: memory pinned
[2017-11-24 17:25:15] : Starting single thread, affinity: 2.
[2017-11-24 17:25:15] : MEMORY ALLOC FAILED: mmap failed
[2017-11-24 17:25:15] : hwloc: memory pinned
[2017-11-24 17:25:15] : Starting single thread, affinity: 3.
[2017-11-24 17:25:15] : MEMORY ALLOC FAILED: mmap failed
[2017-11-24 17:25:15] : hwloc: memory pinned
[2017-11-24 17:25:15] : Starting single thread, affinity: 4.
[2017-11-24 17:25:15] : MEMORY ALLOC FAILED: mmap failed
[2017-11-24 17:25:15] : hwloc: memory pinned
[2017-11-24 17:25:15] : Starting single thread, affinity: 5.
[2017-11-24 17:25:15] : MEMORY ALLOC FAILED: mmap failed
[2017-11-24 17:25:15] : hwloc: memory pinned
[2017-11-24 17:25:15] : Starting single thread, affinity: 6.
[2017-11-24 17:25:15] : MEMORY ALLOC FAILED: mmap failed
[2017-11-24 17:25:15] : hwloc: memory pinned
[2017-11-24 17:25:15] : MEMORY ALLOC FAILED: mmap failed
[2017-11-24 17:25:15] : Fast-connecting to pool.supportxmr.com:5555 pool ...
[2017-11-24 17:25:15] : Pool pool.supportxmr.com:5555 connected. Logging in...
[2017-11-24 17:25:15] : Difficulty changed. Now: 5000.
[2017-11-24 17:25:15] : Pool logged in.
[2017-11-24 17:25:21] : Result accepted by the pool.
[CUDA] Error gpu 0: </home/pascal//xmr-stak/xmrstak/backend/nvidia/nvcc_code/cuda_extra.cu>:244
terminate called after throwing an instance of 'std::runtime_error'
  what():  [CUDA] Error: the launch timed out and was terminated
Aborted (core dumped)

Is there a log file I could post to debug it?

psychocrypt commented 6 years ago

There is only the terminal log. Try to reduce threads in nvidia.txt

pascalwacker commented 6 years ago

So initially I had:

"gpu_threads_conf" :
[
  // gpu: GeForce GT 740M architecture: 35
  //      memory: 1393/2004 MiB
  //      smx: 2
  { "index" : 0,
    "threads" : 104, "blocks" : 6,
    "bfactor" : 0, "bsleep" :  0,
    "affine_to_cpu" : false,
  },

],

I've reduced threads to 70, which made it work, but unfortunately the screen froze, for like 5 minutes, and then I was logged out and the process gone. I'll try some more with lower thread number.

psychocrypt commented 6 years ago

reduce it much more and/or set bfactor to 6.