乐闻世界logo
搜索文章和话题

How to remove cuda completely from ubuntu?

1个答案

1

Completely uninstalling CUDA from Ubuntu typically involves several steps because the CUDA installation includes multiple components, such as drivers, toolkits, and CUDA-related libraries. The following is a step-by-step process:

Step 1: Verify CUDA Version

First, identify the installed CUDA version. This can be done by running the following commands in the terminal:

bash
nvcc --version

or

bash
cat /usr/local/cuda/version.txt

Step 2: Uninstall CUDA Toolkit

Based on the CUDA version identified in Step 1, use the appropriate command to uninstall the CUDA toolkit. If you installed CUDA via apt, use the following commands:

bash
sudo apt-get --purge remove cuda sudo apt-get autoremove

If CUDA was installed by running NVIDIA's .run file, you need to run the same .run file again and select the uninstall option.

Step 3: Uninstall NVIDIA Drivers

CUDA typically installs NVIDIA drivers. If you want to completely remove CUDA, you may also want to uninstall these drivers. Use the following commands:

bash
sudo apt-get --purge remove '*nvidia*' sudo apt-get autoremove

Step 4: Clean Environment Variables

After uninstallation, you may need to edit your .bashrc or .profile file to remove paths pointing to CUDA. Open these files with a text editor, such as:

bash
nano ~/.bashrc

Then locate lines containing /usr/local/cuda and remove or comment them out. Save the file and exit the editor. To apply the changes, run:

bash
source ~/.bashrc

Step 5: Delete CUDA Directory

Finally, to ensure all CUDA-related files are removed, manually delete the CUDA directory:

bash
sudo rm -rf /usr/local/cuda

Step 6: Verify Complete Uninstallation

Finally, restart your computer and verify that CUDA has been completely uninstalled. You can run nvcc --version again; if the system reports that the command is not found, it indicates that CUDA has been successfully uninstalled.

Summary

The above steps should help you completely remove CUDA from your Ubuntu system. Exercise caution when performing these operations, especially when using commands like rm -rf or --purge. Additionally, if operating in a production environment, it is advisable to back up important data first.

2024年8月10日 14:50 回复

你的答案