Running AI on a PC using docker with GPU support

 



             I've successfully run an AI model on my PC using docker, wsl, and other software and packages. It is the easiest way to do the former and other methods were unyielding for me (well some of you may figure it out). Without wasting much time with some unnecessary sentences let's get on to it. 


Prerequisites:

  • WSL
  • Docker Desktop (If you need GUI and the easiest)
  • Good Network connection (If you don't want to be bored to death)
  • PC (Windows or linux(well i'm not doing it for mac))
  • Time

Tutorial (If you need those):





Instructions for CLI:

    Without GPU:

             Without GPU you won't have the speed that is expected for an AI model, but it will work. 


Open wsl directly or using cmd


Update the repositories
Install necessary packages
Fetch Docker GPG key
Add docker repository
Update repositories again
Install docker
Start docker services(for old systems(init))
Start docker services(for new systems)
Add user to docker group to use it without su privileges(optional)
Check if docker is installed(it will show docker help section)
Command to run webui image(and download it if it is not downloaded).
You can give any name you want to the container by renaming pensieve.
Command to run ollama image(and download it if it is not downloaded).
You can give any name you want to the container by renaming dumbledore.
You can use any llm from ollama(i'm using qwen:0.5b).
Replace the name of the model with the one you need.
Open web browser and type:
If all goes well in first try(which never does) you will see







Sign up if you are using it for the first time.


        With GPU(Nvidia):

You may need to install GPU drivers for linux and/or docker containers
GPG key for the official NVIDIA Docker repository
Set up the repository
Update
Install NVIDIA Container Toolkit
Restart the Docker service(new systems)
Restart the Docker service(old systems)
You may need to install nvidia cuda toolkit
Install nvidia cuda toolkit
Command to run webui image(and download it if it is not downloaded). You can give any name you want to the container by renaming pensieve.
Command to run ollama image(and download it if it is not downloaded). You can give any name you want to the container by renaming dumbledore.
All other commands are same as that for the commands without GPU

Instructions for GUI (well partially):

You need to follow the part were you should install the GPU drivers (without running the containers) if you need to use GPU.
Install docker desktop and open it.

Pull ollama and webui images by searching in the search bar.





Get Ollama by searching
Get webui by searching
Run ollama image and open optional settings and type the host port number




Run webui image and open optional settings and type the host port number
Open container which uses ollama.






Go to exec section. You can use any llm from ollama(i'm using deepseek-coder). Replace the name of the model with the one you need.


Go to browser and type


Sign up if you doing it for the first time.
Congratulations for anyone who have finished it especially if you have completed it in first try (well i haven't). This took me months (atleast weeks i think) to find the procedure that works. I haven't shown you how to install the drivers and some other things in my first video so don't die.

You can give any suggestions in youtube comments.


Post a Comment

Previous Post Next Post

Followers