Part 3.2: Installing NVIDIA OptiX on Ubuntu (20.04.01)
Published:
- Graphics Info:
sudo lshw -C video
- C++, IDE (CLion), Compiler (g++), Debugger (gdb)
- CUDA (NVCC)
- OptiX 7.4/ OptiX 7.5
How to Integrate OptiX-CUDA on Ubuntu 22.04
- To check the Ubuntu version:
lsb_release -a
- To find graphics card information:
lspci | grep VGA
orsudo lshw -C video
- To check cuda capable gpu:
0. Remove all older version driver that comes default with Ubuntu (if needed)
- delete all existing old cuda version (<10.1), that may create
#error -- unsupported GNU version! gcc versions later than 8 are not supported!
, following these:sudo apt-get purge nvidia* sudo apt-get autoremove nvidia* sudo apt-get autoclean nvidia* (if necessary) sudo rm -rf /usr/local/cuda* (if necessary)
1. Graphics Driver Update:
- type
nvidia-smi
in the terminal- If all older version nvidia driver uninstalled (from previous step), this will give option to install the newer/ latest version using
sudo apt install
command, e.g.,sudo apt install nvidia-utils-510
- But not all latest GPU driver versions are available
- in that case:
sudo add-apt-repository ppa:graphics-drivers/ppa
- then:
Software & Updates --> Additional Drivers
- in that case:
- If all older version nvidia driver uninstalled (from previous step), this will give option to install the newer/ latest version using
- ~You can use this post to update your graphics driver~
Troubleshooting:
// problem 1: if screen color is green, that is color calibration problem
setting >> color calibration >> monitor name >> delete attached color profile >> add Standard space sRGB profile
// problem 2: if stuck in x.Org x server
1. nvidia-smi
2. sudo apt install nvidia-utils-515
// error message
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.
3. sudo add-apt-repository ppa:graphics-drivers/ppa
4. sudo ubuntu-drivers list
nvidia-driver-470, (kernel modules provided by linux-modules-nvidia-470-generic-hwe-22.04)
nvidia-driver-470-server, (kernel modules provided by linux-modules-nvidia-470-server-generic-hwe-22.04)
nvidia-driver-510-server, (kernel modules provided by linux-modules-nvidia-510-server-generic-hwe-22.04)
nvidia-driver-515-server, (kernel modules provided by linux-modules-nvidia-515-server-generic-hwe-22.04)
nvidia-driver-520, (kernel modules provided by linux-modules-nvidia-520-generic-hwe-22.04)
nvidia-driver-520-open, (kernel modules provided by nvidia-dkms-520-open)
nvidia-driver-515-open, (kernel modules provided by nvidia-dkms-515-open)
nvidia-driver-515, (kernel modules provided by linux-modules-nvidia-515-generic-hwe-22.04)
nvidia-driver-510, (kernel modules provided by linux-modules-nvidia-510-generic-hwe-22.04)
5. sudo apt install nvidia-driver-520
2. Download CUDA Toolkit (e.g., CUDA 11.6, you can use any other latest version as well)
nvcc --version
- From NVIDIA Site Download LATEST CUDA TOOLKIT
2.1. Set CUDA to library path (PATH and LD_LIBRARY_PATH) is often required for other libraries as well
// either these two lines work to add in root
export "PATH=$PATH:/usr/local/cuda-11.6/bin" >> ~/.bashrc
export "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.6/lib64" >> ~/.bashrc
// source ~/.bashrc (what does this command do?)
// or these two lines as above
sudo echo "PATH=$PATH:/usr/local/cuda-11.6/bin" >> ~/.bashrc
sudo echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.6/lib64" >> ~/.bashrc
3. Download OptiX and Set directory
sudo chmod +x file_name.sh
./file_name.sh
// read the agreement until 8.11
// set the environment variable `OptiX_INSTALL_DIR`
export OptiX_INSTALL_DIR=/home/bmohanto/Downloads/NVIDIA-OptiX-SDK-7.4.0-linux64-x86_64 //(no gap between `=`)
// above line did not work on latest Ubuntu 22.04 LTS, replace with
sudo echo "OptiX_INSTALL_DIR=/home/vcg0/NVIDIA-OptiX-SDK-7.5.0-linux64-x86_64" >> ~/.bashrc
3.1. Install the pre-requisites (if needed, or can do later according to need)
sudo apt -y install dkms libglfw3-dev pkg-config libglvnd-dev
// ~if cpp package not installed~
// install before cuda toolkit installation
build-essential
// if freeglut needed freeglut3-dev
// cmake-curses-gui
libtbb-dev
//git gitk
- ~Package ‘emacs25’ has no installation candidate~ (this is an editor)
4. BUILD and RUN with CMAKE (either from terminal/ use GUI)
// for OptiX 7.5, pre-rquired: (depends on your setting, you might need more or less packages)
sudo apt install doxygen libopenexr-dev zlib1g zlib1g-dev libgl1-mesa-dev libglfw3-dev libxinerama-dev libxcursor-dev -y
// to check installed library:
dpkg -L libLIBRARY_NAME-dev
// to remove library
sudo apt autoremove libLIBRARY_NAME-dev
cmake ..
make
/make -j 8
(for parallel, 8 is the number of CPU cores)- To see the core information, type
lscpu
, and see:CPU(s): e.g., 6 Thread(s) per core: e.g., 2 Core(s) per socket:
nproc
or,cat /proc/cpuinfo | grep preprocessor | wc -l
also can work
<img src="https://user-images.githubusercontent.com/12484581/165559399-7d3ed7a4-74ca-4675-8451-8e89254d5960.png" width=350px\>
Trouble Shooting
- If
nvcc
problem, install latest driver, and cuda toolkit. The Cmake Configuration as below:
<img src="https://user-images.githubusercontent.com/12484581/163886737-d8b826b9-1040-4b1c-bcc2-51ec28ea0556.png", width="700", height = "400">
- If
bin2c
not found: (/bin/sh: 1: BIN2C-NOTFOUND: not found)
// try 1
goto all: CMakeCache.txt
-BIN2C:FILEPATH=/usr/local/cuda-11.6/bin/bin2c
+ set(BIN2C /usr/local/cuda-11.7/bin/bin2c)
// Try 2: if above modification does not work
goto: configure_optix.cmake
// comment these two lines
-find_program(BIN2C bin2c
-DOC "Path to the cuda-sdk bin2c executable.")
+set(BIN2C /usr/local/cuda-11.7/bin/bin2c)
// Try 3: if these two do not work, keep trying 2 and delete all CMakeCache.txt files. Make a clean CMake Build
- If
OptiX_INCLUDE_DIR
not found message shown
goto `FindOptiX.cmake` in `common>> gdt >> cmake` folder and replace the
- set(OptiX_INSTALL_DIR ${searched_OptiX_INSTALL_DIR} CACHE PATH "Path to OptiX installed location.")
+ set(OptiX_INSTALL_DIR "/home/bmohanto/Downloads/NVIDIA-OptiX-SDK-7.4.0-linux64-x86_64")
- ZlibStatic_ROOT (CMake Error: The Xinerama library and headers were not found)
Solution: sudo apt install xorg-dev
<img src=”https://user-images.githubusercontent.com/12484581/165559278-29d25a92-44dd-42c7-8685-11930e963b7f.png” width=400px> Fig: Final CMake BUILD
5. OptiX headers (optix.h and friends) not found Please locate before proceeding.
Update the FindOptiX.cmake with set(OptiX_INSTALL_DIR “/home/bmohanto/Downloads/NVIDIA-OptiX-SDK-7.4.0-linux64-x86_64”). This solved the first problem, but lead to another BIN2CC not found, although I have defined bin2cc in cmake build.
This https://github.com/ingowald/optix7course/issues/28 helped me, I have manually modified the CMakeCache.txt and configure_optix.cmake with set(BIN2C /usr/local/cuda-11.6/bin/bin2c). This solved the BIN2CC problem, but lead me to another compile time error.
So finally I deleted all the CMakeCache.txt files, but kept the configure_optix.cmake with set(BIN2C /usr/local/cuda-11.6/bin/bin2c) and made a fresh cmake build.