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

OS:Ubuntu: Nvidia GPU #158

Open
xvno opened this issue Aug 20, 2021 · 5 comments
Open

OS:Ubuntu: Nvidia GPU #158

xvno opened this issue Aug 20, 2021 · 5 comments

Comments

@xvno
Copy link
Owner

xvno commented Aug 20, 2021

Refs

NVidia Drivers downloading page

@xvno
Copy link
Owner Author

xvno commented Aug 20, 2021

Step by step

1. disable nouveau

sudo bash -c "echo blacklist nouveau > /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
sudo bash -c "echo options nouveau modeset=0 >> /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
sudo update-initramfs -u
# sudo reboot

lsmod | grep nou # check nouveau is not running

2. Install driver

2.1 Check devices:

sudo lshw -C display

Result

*-display                 
       description: VGA compatible controller
       product: NVIDIA Corporation
       vendor: NVIDIA Corporation
       physical id: 0
       bus info: pci@0000:01:00.0
       logical name: /dev/fb0
       version: a1
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress vga_controller bus_master cap_list rom fb
       configuration: depth=32 driver=nouveau latency=0 mode=3840x2160 visual=truecolor xres=3840 yres=2160
       resources: iomemory:600-5ff iomemory:620-61f irq:186 memory:a0000000-a0ffffff memory:6000000000-61ffffffff memory:6200000000-6201ffffff ioport:3000(size=128) memory:a1000000-a107ffff
  *-display
       description: VGA compatible controller
       product: UHD Graphics
       vendor: Intel Corporation
       physical id: 2
       bus info: pci@0000:00:02.0
       version: 05
       width: 64 bits
       clock: 33MHz
       capabilities: pciexpress msi pm vga_controller bus_master cap_list rom
       configuration: driver=i915 latency=0
       resources: iomemory:620-61f iomemory:400-3ff irq:187 memory:6202000000-6202ffffff memory:4000000000-400fffffff ioport:4000(size=64) memory:c0000-dffff

2.2 Download the appropriate driver for the gpu devicee and run

curl https://us.download.nvidia.cn/XFree86/Linux-x86_64/470.63.01/NVIDIA-Linux-x86_64-470.63.01.run -o NVIDIA-Linux-x86_64-470.63.01.run
sudo chmod a+x NVIDIA-Linux-x86_64-470.63.01.run
sudo ./NVIDIA-Linux-x86_64-470.63.01.run
One or more modprobe configuration files to disable Nouveau have been written.  For some distributions, this may be sufficient to disable Nouveau; other distributions may require modification of the initial ramdisk.  Please 
  reboot your system and attempt NVIDIA driver installation again.  Note if you later wish to re-enable Nouveau, you will need to delete these files: /usr/lib/modprobe.d/nvidia-installer-disable-nouveau.conf,
  /etc/modprobe.d/nvidia-installer-disable-nouveau.conf

@xvno
Copy link
Owner Author

xvno commented Aug 20, 2021

3. install CUDA

sudo apt install nvidia-cuda-toolkit
nvcc -V

Not so ideal... so try this:

wget https://developer.download.nvidia.com/compute/cuda/11.4.1/local_installers/cuda_11.4.1_470.57.02_linux.run
sudo sh cuda_11.4.1_470.57.02_linux.run

@xvno
Copy link
Owner Author

xvno commented Aug 20, 2021

4. Reinstall CUDA

sudo apt purge nvidia-cuda-toolkit
#Run NVIDIA driver installer again but it returns error. restart the server

# Switch a default GCC version
sudo apt -y install gcc-7 g++-7
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 7
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 7

# Install from installer
curl http://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_440.33.01_linux.run -o cuda_10.2.89_440.33.01_linux.run
chmod u+x cuda_10.2.89_440.33.01_linux.run
sudo sh cuda_10.2.89_440.33.01_linux.run

Add in .bashrc

PATH=/usr/local/cuda-10.2/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64

Add in /etc/ld.so.conf.

include /usr/local/cuda-10.2/lib64

@xvno
Copy link
Owner Author

xvno commented Aug 20, 2021

5. Sample CUDA code to test

git clone https://github.com/NVIDIA/cuda-samples.git
cd cuda-samples/Samples/simpleCUBLAS
vim Makefile
# Change the Location of the CUDA Toolkit
# CUDA_PATH ?= /usr/lib/nvidia-cuda-toolkit
mkake
./simpleCUBLAS

@xvno
Copy link
Owner Author

xvno commented Aug 20, 2021

Add in .bashrc

PATH=/usr/local/cuda-10.2/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64

Add in /etc/ld.so.conf.

include /usr/local/cuda-10.2/lib64

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

1 participant