Installing and using DeepSeek AI
DeepSeek R1 recently gained notoriety for its advanced reasoning capabilities. From a privacy standpoint, having the ability to run an AI model entirely offline (and with limited resources) is a significant advantage.
By processing data locally, organizations can keep sensitive or regulated information on-premises, reducing the risk of data leaks. In this post, we’ll set up DeepSeek on a Linux system, use a GUI for interaction, and integrate it into a Python script.
1. Installing CUDA on WSL
Depending on your setup, you can go directly to the second section of this article. In my setup, I used WSL. To enable CUDA in Ubuntu, I generally follow these steps:
sudo apt update
sudo apt install build-essential
wget https://developer.download.nvidia.com/compute/cuda/12.6.2/local_installers/cuda_12.6.2_560.35.03_linux.run
sudo sh cuda_12.6.2_560.35.03_linux.run
My nvidia-smi
output:
You can also check the success of the installation with the script /usr/local/cuda-12.6/extras/demo_suite/deviceQuery
.
2. Install Ollama
Ollama is a powerful tool that enables new ways to create and run LLM applications in the cloud. It simplifies the development process and offers flexible deployment options, as well as easy management and scaling of applications. You can download and install it with:
curl -fsSL https://ollama.com/install.sh | sh
3. Download DeepSeek
Finally we can download the DeepSeek model. DeepSeek-R1 comes with multiple distilled models derived from Qwen and Llama architectures, each tailored to meet distinct performance and resource needs.
The sizes of these models vary. For example, the 1.5b model is around 2.3 GB, the 7b model is roughly 4.7 GB, and the 70b model exceeds 40 GB. In my case, I went with the default deepseek-r1 model.
The 1.5b model requires fewer resources, while models like 14b and 32b are geared toward higher performance. Check all models here.
As you can see in the image, it immediately switches to a prompt after downloading. In this example, I asked about ransomware, and it provided some quite impressive details.
4. Using Chatbox
Chatbox offers a user-friendly interface for interacting with AI models. After installation, open Settings, choose “OLLAMA API” as the Model Provider, and select the DeepSeek model you prefer. It will automatically recognize the recently installed models if there were no errors.
In the following image, I asked it to generate a Python script capable of downloading a file called not_malicious.zip
from a remote server, and it did so with quite interesting details. The script even checks the status code and handles potential exceptions.
5. Python example
DeepSeek provides an API that’s fully compatible with ChatGPT. You can simply run pip3 install openai
to get started. In my setup, I’ll be using the ollama
Python package instead.
python3 -m venv venv
source venv/bin/activate
pip3 install ollama
I created a simple script that asks for five cyber security best practices from the model, and here is the result:
Conclusion
AI models are here to stay in our daily lives. Having the ability to run a model offline, even with limited computational resources, is a huge advantage compared to closed-source models.
This opens up multiple possibilities for both defenders and attackers from a cybersecurity standpoint. While a defender can use it for learning, improving scripts, and detecting malicious behavior, an attacker may use it to generate ransomware or craft convincing phishing campaigns.
I’m very curious to see what awaits us in this field in the coming years.