CivArchive
    ← All articles
    Published December 21, 2024by sdimg

    Linux Nvidia Drivers + CUDA + Miniconda Tutorial Guide for Ubuntu based OS like Mint etc...

    735 views8 reactions2 comments on CivitAI15 collected
    lora trainingubuntuhunyuan videofluxhunyuandriversminicondageneratinglinuxnvidiacudaresource guide
    • This should help to get the basics of a fresh linux install working properly with current nvidia drivers (560), cuda (12.6) and miniconda (python 3.10, 3.11, 3.12 etc).

    • Many linux guides don't adequately explain these important steps to get things setup right.

    • This guide presumes you are able to install an ubuntu based linux distro safely to empty ssd.

    • If not check youtube for guides and i recommend unplugging all other drives before installing if unsure.

    • It should also work if you're using Windows WSL, although i've not tested so check second video as driver install may not be needed.

    • After linux is installed go to update manager and install any updates.

    • If you have any issues or prefer videos then these are very helpful.

    • Install Nvidia Drivers on Ubuntu

    • Install Ubuntu WSL + CUDA + Miniconda

    • Open terminal and copy/paste the following command lines one at a time.

    • Check current nvidia driver version and install 560.

    nvidia-smi
    sudo add-apt-repository ppa:graphics-drivers/ppa
    sudo apt update
    sudo apt install nvidia-driver-560
    • Reboot PC.

    • Check version is correct and install CUDA.

    nvidia-smi
    sudo apt install -y build-essential
    wget https://developer.download.nvidia.com/compute/cuda/12.6.3/local_installers/cuda_12.6.3_560.35.05_linux.run
    sudo sh cuda_12.6.3_560.35.05_linux.run
    • After accepting make sure to uncheck drivers 560 at top of menu if they are selected.

    sudo apt update
    sudo apt upgrade
    nano ~/.bashrc
    • Press the down arrow and copy this text to end of file.

    export PATH=/usr/local/cuda-12.6/bin${PATH:+:${PATH}}
    export LD_LIBRARY_PATH=/usr/local/cuda-12.6/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
    • Press ctrl+o to save then ctrl+x to exit.

    source ~/.bashrc
    • Check cuda is working.

    nvcc --version
    • Install miniconda.

    wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
    bash ./Miniconda3-latest-Linux-x86_64.sh
    • Press enter > pgdn > yes > enter > yes

    • Close terminal then open terminal, you should see (base) at start and python should be 3.10.

    • You may also need if asked.

    sudo apt update -y && sudo apt install -y python3-tk
    python --version
    sudo apt install git
    • You can stop here and install any generator or trainer using existing guides.

    • Recommended to increase swapfile size to 32gb to avoid crashing!

    sudo swapon --show
    sudo swapoff -a
    sudo dd if=/dev/zero of=/swapfile bs=1M count=32768 status=progress
    sudo chmod 600 /swapfile
    sudo mkswap /swapfile
    sudo swapon /swapfile
    sudo swapon --show
    sudo nano /etc/fstab
    • Add the following line to the end of the file if it doesn't exist.

    /swapfile none swap sw 0 0
    • Bonus if using linux mint (not tested on ubuntu) you can disable the os gui and run like a server from command line.

    • This saves a small amount of vram and performance.

    sudo nano /etc/default/grub
    • Change "quiet splash" to "text"

    • Press ctrl+o to save then ctrl+x to exit.

    sudo update-grub
    sudo systemctl set-default multi-user.target
    • Reboot PC.

    • Login and press up arrow to switch to whatever training/generating folders scripts you use.

    • To open desktop.

    startx
    pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu124
    pip install -r requirements.txt
    • Run ComfyUI with --listen 0.0.0.0 to access from another browser on network to save performance otherwise remove.

    cd ComfyUI
    python main.py --listen 0.0.0.0
    cd ComfyUI/custom_nodes
    git clone https://github.com/ltdrdata/ComfyUI-Manager.git

    Hopefully this is helpful to anyone struggling with basic linux setup. Let me know how it goes! :)