Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No CMAKE_CUDA_COMPILER could be found (solved) #13

Closed
dan9thsense opened this issue Aug 20, 2018 · 13 comments
Closed

No CMAKE_CUDA_COMPILER could be found (solved) #13

dan9thsense opened this issue Aug 20, 2018 · 13 comments

Comments

@dan9thsense
Copy link

dan9thsense commented Aug 20, 2018

I have a similar issue to issue #12 but am unable to fix it (SOLVED-- see answer below). I am installing with CUDA 9.0 and the path to the compiler is in the usual location, /usr/local/cuda-9.0/bin/nvcc. The install with the script installLibrealsens.sh works fine without CUDA but fails when CUDA is selected.

The error is:
CMake Error at CMakeLists.txt:7 (project):
No CMAKE_CUDA_COMPILER could be found.
Tell CMake where to find the compiler by setting either the environment
variable "CUDACXX" or the CMake cache entry CMAKE_CUDA_COMPILER to the full
path to the compiler, or to the compiler name if it is in the PATH.

I tried to export CUDACXX as /usr/local/cuda-9.0/bin and also as /usr/local/cuda-9.0/bin/nvcc and also as nvcc
but none of those helped. The PATH also contains /usr/local/cuda-9.0/bin

I tried modifying the CMakeLists.txt file that is generated with the CUDA option off. I changed the CUDA option to ON and added this line to the CUDA section:
set(CMAKE_CUDA_COMPILER /usr/local/cuda-9.0/bin/nvcc)
but I don't know how to use that CMakeLists.txt file to drive a new compile. If I just use "make" it does not update the compilation.

UPDATE: It has to do with ownership. If I run installLibrealsens.sh without sudo, then it finds the CUDA compiler but fails with:

/usr/local/cuda-9.0/bin: Permission denied

If I run the script as sudo, either with or without the -E option to keep environment variables, then it cannot find the CUDA compiler.

ANSWERED:
put
CUDACXX=/usr/local/cuda-9.0/bin/nvcc
into /etc/environment so that it is applied when using sudo.

@dan9thsense dan9thsense changed the title No CMAKE_CUDA_COMPILER could be found. No CMAKE_CUDA_COMPILER could be found (solved) Aug 21, 2018
@lucasjinreal
Copy link

Its still got some error:

[ 85%] Linking CUDA device code CMakeFiles/spconv.dir/cmake_device_link.o
nvcc fatal   : Unknown option 'Wl,--no-as-needed,/media/jintain/sg/ai/career/robot/ctirobot/fruits/3d_det/second_pytorch/spconv/libtorch/lib/libcaffe2.so'
src/spconv/CMakeFiles/spconv.dir/build.make:192: recipe for target 'src/spconv/CMakeFiles/spconv.dir/cmake_device_link.o' failed
make[2]: *** [src/spconv/CMakeFiles/spconv.dir/cmake_device_link.o] Error 1
CMakeFiles/Makefile2:108: recipe for target 'src/spconv/CMakeFiles/spconv.dir/all' failed
make[1]: *** [src/spconv/CMakeFiles/spconv.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 92%] Linking CXX shared library ../../../lib.linux-x86_64-3.6/spconv/spconv_utils.cpython-36m-x86_64-linux-gnu.so
[ 92%] Built target spconv_utils
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
Traceback (most recent call last):
  File "setup.py", line 82, in <module>
    zip_safe=False,
  File "/usr/local/lib/python3.6/dist-packages/setuptools/__init__.py", line 140, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib/python3.6/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/lib/python3.6/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/usr/local/lib/python3.6/dist-packages/setuptools/command/install.py", line 67, in run
    self.do_egg_install()
  File "/usr/local/lib/python3.6/dist-packages/setuptools/command/install.py", line 109, in do_egg_install
    self.run_command('bdist_egg')
  File "/usr/lib/python3.6/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/usr/local/lib/python3.6/dist-packages/setuptools/command/bdist_egg.py", line 172, in run
    cmd = self.call_command('install_lib', warn_dir=0)
  File "/usr/local/lib/python3.6/dist-packages/setuptools/command/bdist_egg.py", line 158, in call_command
    self.run_command(cmdname)
  File "/usr/lib/python3.6/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/usr/local/lib/python3.6/dist-packages/setuptools/command/install_lib.py", line 11, in run
    self.build()
  File "/usr/lib/python3.6/distutils/command/install_lib.py", line 109, in build
    self.run_command('build_ext')
  File "/usr/lib/python3.6/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "setup.py", line 35, in run
    self.build_extension(ext)
  File "setup.py", line 66, in build_extension
    subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd=self.build_temp)
  File "/usr/lib/python3.6/subprocess.py", line 291, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--config', 'Release', '--', '-j4']' returned non-zero exit status 2.

@jetsonhacks
Copy link
Owner

Linking CXX shared library ../../../lib.linux-x86_64-3.6
It appears as if you are trying to compile this on a PC. This is for a NVIDIA Jetson ARM machine.

@lucasjinreal
Copy link

Sorry, this is an issue referenced to here, it's an issue about @travller59's library

@ansabsheikh9
Copy link

@jinfagang are you able to solve the problem? I am also facing the same error

@darshanz
Copy link

Is the problem solved? I am also facing the same problem on Jetson TX2.

@gachiemchiep
Copy link

@darshanz

Add these line to your ~/.bashrc and reload the terminal. After that cmake will find the nvcc

# cuda 10.2
export CUDA_HOME=/usr/local/cuda
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64
export PATH=$PATH:$CUDA_HOME/bin

@lgldl
Copy link

lgldl commented Jun 22, 2020

Its still got some error:

[ 85%] Linking CUDA device code CMakeFiles/spconv.dir/cmake_device_link.o
nvcc fatal   : Unknown option 'Wl,--no-as-needed,/media/jintain/sg/ai/career/robot/ctirobot/fruits/3d_det/second_pytorch/spconv/libtorch/lib/libcaffe2.so'
src/spconv/CMakeFiles/spconv.dir/build.make:192: recipe for target 'src/spconv/CMakeFiles/spconv.dir/cmake_device_link.o' failed
make[2]: *** [src/spconv/CMakeFiles/spconv.dir/cmake_device_link.o] Error 1
CMakeFiles/Makefile2:108: recipe for target 'src/spconv/CMakeFiles/spconv.dir/all' failed
make[1]: *** [src/spconv/CMakeFiles/spconv.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 92%] Linking CXX shared library ../../../lib.linux-x86_64-3.6/spconv/spconv_utils.cpython-36m-x86_64-linux-gnu.so
[ 92%] Built target spconv_utils
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
Traceback (most recent call last):
  File "setup.py", line 82, in <module>
    zip_safe=False,
  File "/usr/local/lib/python3.6/dist-packages/setuptools/__init__.py", line 140, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib/python3.6/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/lib/python3.6/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/usr/local/lib/python3.6/dist-packages/setuptools/command/install.py", line 67, in run
    self.do_egg_install()
  File "/usr/local/lib/python3.6/dist-packages/setuptools/command/install.py", line 109, in do_egg_install
    self.run_command('bdist_egg')
  File "/usr/lib/python3.6/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/usr/local/lib/python3.6/dist-packages/setuptools/command/bdist_egg.py", line 172, in run
    cmd = self.call_command('install_lib', warn_dir=0)
  File "/usr/local/lib/python3.6/dist-packages/setuptools/command/bdist_egg.py", line 158, in call_command
    self.run_command(cmdname)
  File "/usr/lib/python3.6/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/usr/local/lib/python3.6/dist-packages/setuptools/command/install_lib.py", line 11, in run
    self.build()
  File "/usr/lib/python3.6/distutils/command/install_lib.py", line 109, in build
    self.run_command('build_ext')
  File "/usr/lib/python3.6/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "setup.py", line 35, in run
    self.build_extension(ext)
  File "setup.py", line 66, in build_extension
    subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd=self.build_temp)
  File "/usr/lib/python3.6/subprocess.py", line 291, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--config', 'Release', '--', '-j4']' returned non-zero exit status 2.

I got the same error with you, have you solved it?

@alokkushawaha
Copy link

Make sure that you install CUDA after visual studio installation. I solved mine problem using that. Since CUDA visual studio integration doesn't work if visual studio is installed later.

@maaydi
Copy link

maaydi commented Feb 28, 2022

adding CMAKE_CUDA_COMPILER(nvcc path) before calling project in the CMakeLists.txt file works fo me :


cmake_minimum_required(VERSION 3.21)

set(CMAKE_CUDA_COMPILER /usr/local/cuda/bin/nvcc)

project(my_project_name CUDA)

@LILILILILIYIRAN
Copy link

Thanks. This method can solve my problem.

@yahskapar
Copy link

ANSWERED: put CUDACXX=/usr/local/cuda-9.0/bin/nvcc into /etc/environment so that it is applied when using sudo.

This worked for me when it seemed like the wrong CUDA compiler was being picked up by cmake. Thanks!

@GopherJ
Copy link

GopherJ commented May 13, 2024

set(CMAKE_CUDA_COMPILER /usr/bin/nvcc)

worked for me

@gundeep-dialpad
Copy link

it worked after this on ubuntu 22.04

sudo apt install nvidia-cuda-toolkit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests