# Reinstall Driver NVIDIA on Linux

Reinstalling NVIDIA drivers on a Linux operating system is an important process to ensure optimal performance of your hardware, especially when experiencing degraded performance issues. This guide will cover the detailed steps required to reinstall NVIDIA drivers on Linux to help you maximize the performance and stability of your system.

{% hint style="danger" %}
If after following the guide below and the error still occurs, your system needs to reboot.
{% endhint %}

## Uninstall NVIDIA Driver Already Installed

In the first stage, removing the installed NVIDIA driver is logging in as a super user.

```bash
sudo su
```

Displays a list of NVIDIA Driver packages that are already installed on the system by executing the following syntax.

```bash
apt list nvidia-driver* | grep installed
```

In the list there is a driver "nvidia-driver-550", delete the driver by running the following syntax.

```bash
apt remove nvidia-driver-550
```

Run this command to remove packages that are no longer needed by the system.

```bash
apt autoremove
```

After successfully deleting the NVIDIA driver and packages that are no longer needed by the system, then restart the system by running the following syntax.

```bash
reboot
```

## Install New Driver NVIDIA

Download the CUDA keyring package by executing the following syntax.

```bash
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
```

Install the CUDA keyring package that has been successfully downloaded by running the following syntax.

```bash
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt-get update
```

After running the syntax to install the CUDA keyring package, the next step is to install the CUDA driver and fabric manager to the system. Run the following syntax.

```bash
apt install cuda-drivers-550 cuda-drivers-fabricmanager-550
```

## Check Installation

Check the installation results using nvidia-smi by running the following command.

```bash
nvidia-smi
```

<figure><img src="https://2882153758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9YWb69HFXLHYlXffReU%2Fuploads%2FBvYP7BFp257rEdqB41Kv%2Fimage.png?alt=media&#x26;token=ad9826e1-5cf7-4587-aa83-d8575e5fb5b6" alt=""><figcaption></figcaption></figure>

## Enable and Start Service

To manage the nvidia-fabricmanager service that is installed on a Linux system, you need to run some syntax to activate the service by running the following syntax.

{% hint style="danger" %}
If you use baremetal and H100 GPU type. You can run the syntax below.
{% endhint %}

```bash
systemctl enable nvidia-fabricmanager
systemctl start nvidia-fabricmanager
systemctl status nvidia-fabricmanager
```

## Configure CUDA Toolkit

Install CUDA Toolkit on your system by executing the following syntax.

```bash
apt-get -y install cuda-toolkit-12-4
```

The next stage is to configure the installed CUDA Toolkit path by creating a cuda.sh profile file.

```bash
nano /etc/profile.d/cuda.sh
```

Adding the following path.

```bash
export PATH=$PATH:/usr/local/cuda/bin
```

Update the bashrc file.

```bash
nano ~/.bashrc
```

add the path to the last line.

```bash
export PATH=$PATH:/usr/local/cuda/bin
```

Check the version of nvcc used, log out and log back in to load the variables used.

```bash
nvcc –version
```

<figure><img src="https://2882153758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9YWb69HFXLHYlXffReU%2Fuploads%2FZb3UeomwSbZtB1WOYqN7%2Fimage.png?alt=media&#x26;token=efd45bfd-c0ba-4e2f-a9b3-cc9ac4612a66" alt=""><figcaption></figcaption></figure>

## **Install Python3**&#x20;

Install Python3 and pip install torch, torchvision, torchaudio and transformers by executing the following syntax.&#x20;

```bash
apt install python3 python3-pip
```

```bash
pip3 install torch torchvision torchaudio
pip install transformers
```

## Testing

Log in to Python3 and run the following code to test if CUDA is available:

```python
import torch 
torch.cuda.is_available() 
torch.cuda.current_device() 
torch.cuda.device(0)
```

<figure><img src="https://2882153758-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9YWb69HFXLHYlXffReU%2Fuploads%2FyS47mJLdbxdhxqWgycug%2Fimage.png?alt=media&#x26;token=7cb5140a-42e2-4dfb-87b0-c71b17abb2ab" alt=""><figcaption></figcaption></figure>
