https://cristianzsh.medium.com/installing-and-using-deepseek-ai-c7fd97332e0f
-
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:
-
Install Ollama (Ollama is an open-source framework designed to facilitate the deployment of large language models on local environments.)
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
-
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 https://ollama.com/library/deepseek-r1 (DeepSeek’s first-generation of reasoning models with comparable performance to OpenAI-o1, including six dense models distilled from DeepSeek-R1 based on Llama and Qwen.).
ollama run deepseek-r1 #DeepSeek-R1-Distill-Qwen-1.5B (通义千问 by Alibaba) ollama run deepseek-r1:1.5b #DeepSeek-R1-Distill-Qwen-7B ollama run deepseek-r1:7b #DeepSeek-R1-Distill-Llama-8B ollama run deepseek-r1:8b #DeepSeek-R1-Distill-Qwen-14B ollama run deepseek-r1:14b #DeepSeek-R1-Distill-Qwen-32B ollama run deepseek-r1:32b #DeepSeek-R1-Distill-Llama-70B (The open-source AI models by Meta you can fine-tune, distill and deploy anywhere. Choose from our collection of models: Llama 3.1, Llama 3.2, Llama 3.3.) #https://github.com/ollama/ollama Llama 3.3 70B 43GB "ollama run llama3.3" ollama run deepseek-r1:70b
As you can see in the image, it immediately switches to a prompt after downloading.
Write me a pyhton script to download the file not_malicious.zip from localhost on TCP port 443.
以下是一个简单的Python脚本,使用
requests
库从localhost的TCP端口443下载文件not_malicious.zip
。此脚本假设文件通过HTTPS协议提供服务,并且localhost运行了一个支持HTTPS的服务器:```python import requests def download_file(url, filename): try: # 发送HTTP GET请求 response = requests.get(url) # 检查是否请求成功 if response.status_code == 200: # 将内容保存到文件中 with open(filename, 'wb') as file: file.write(response.content) print(f"成功下载文件并保存为 {filename}") else: print(f"无法下载文件,状态码:{response.status_code}") except Exception as e: print(f"发生错误:{str(e)}") # URL假设为localhost的TCP端口443(HTTPS) url = "https://localhost:443/not_malicious.zip" filename = "not_malicious.zip" download_file(url, filename) ``` ### 依赖项 在运行此脚本之前,确保已经安装了`requests`库。你可以使用以下命令进行安装: ```bash pip install requests ``` ### 注意事项: 1. **HTTPS证书**:如果服务器使用自签名证书,可能会出现SSL验证错误。可以通过设置`verify=False`来绕过此检查(不推荐用于生产环境): ```python response = requests.get(url, verify=False) ``` 2. **权限问题**:确保脚本有权限写入目标文件夹。 3. **服务器配置**:确认localhost的TCP端口443上正在运行一个HTTPS服务器,并且`not_malicious.zip`文件在该服务器上可访问。 4. **安全性**:仅从信任的来源下载文件。确保你了解`not_malicious.zip`的内容。 5. **错误处理**:此脚本包含基本的错误处理,你可以根据需要添加更多的错误检查和异常处理逻辑。 如果服务器未正确配置或文件路径不正确,可能会导致下载失败。在运行脚本之前,请确保所有服务已正确设置。
-
Using Chatbox (https://chatboxai.app/en) GUI
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.
-
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 #-->Defaulting to user installation because normal site-packages is not writeable #-->Requirement already satisfied: ollama in /home/jhuang/.local/lib/python3.10/site-packages (0.4.7) import ollama response = ollama.chat(model="deepseek-r1:70b", messages=[{"role":"user", "content":"Tell me the most beatiful chinese city.",},]) print(response["message"]["content"]) python3 deepseek_test1.py > most_beatiful_chinese_city.txt
The question of which Chinese city is the most beautiful can be answered by considering various aspects such as natural scenery, historical architecture, and cultural significance. Here are some of the top contenders:
1. **Guilin**: Renowned for its stunning karst mountains and scenic rivers, Guilin is often depicted in traditional paintings and films, making it a top choice for natural beauty.
2. **Hangzhou**: Famous for West Lake, a UNESCO World Heritage site, Hangzhou combines natural beauty with historical and cultural significance, enhancing its allure.
3. **Suzhou**: Known as the "Venice of the East," Suzhou boasts canals and classical gardens that exemplify Chinese garden design, offering a blend of natural and man-made beauty.
4. **Lijiang**: With its well-preserved old town and traditional Naxi architecture, Lijiang is a UNESCO site that charms visitors with its cobblestone streets and historic ambiance.
5. **Pingyao**: This ancient city is celebrated for its Ming-era architecture and well-preserved city walls, offering a glimpse into China's rich history.
6. **Jiuzhaigou**: Known for its colorful lakes and waterfalls, Jiuzhaigou is a natural wonder that attracts visitors with its vibrant landscapes.
While each city has unique qualities, Guilin is often highlighted as one of the most beautiful due to its iconic natural landscapes. However, Hangzhou and Suzhou are strong contenders because they effectively blend nature with cultural and historical elements. Ultimately, the choice depends on the aspect of beauty being emphasized—natural, historical, or cultural.
-
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 am very curious to see what awaits us in this field in the coming years.