新服务器从0开始搭配Ubuntu+Conda+Docker+Dify

新到一台服务器,4090显卡,需要投喂文件, 搭建个RAG, AI对话框出来,过程:

1 Ubuntu

下载: https://cn.ubuntu.com/download 24.4 记住这个版本号

注意:企业级硬盘要做raid1+raid5.

2 安装显卡驱动和CUDA Toolkit,

bash 复制代码
watch -n 3 -d nvidia-smi     #每隔3秒刷新一次

https://developer.nvidia.com/cuda-12-9-0-download-archive?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=24.04&target_type=runfile_local

选择到合适的版本

bash 复制代码
wget https://developer.download.nvidia.com/compute/cuda/12.9.0/local_installers/cuda_12.9.0_575.51.03_linux.run
sudo sh cuda_12.9.0_575.51.03_linux.run

打开终端,配置环境:

bash 复制代码
vim ~/.bashrc

最后添加:

bash 复制代码
export PATH=$PATH:/usr/local/cuda-12.9/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-12.9/lib64

打开终端输入:

bash 复制代码
source ~/.bashrc

最后终端输入nvcc -V即可查看CUDA版本:

3 安装 VPN

参考:

1 https://www.youtube.com/watch?v=1d-HT_xF94w

2 https://github.com/kjfx/vpn/releases/tag/linux

bash 复制代码
sudo apt update
sudo apt install bzip2 tar
sudo apt-get install curl

sudo -i #切换到root用户

bash 复制代码
export url='https://fastly.jsdelivr.net/gh/juewuy/ShellCrash@master' && wget -q --no-check-certificate -O /tmp/install.sh $url/install.sh  && bash /tmp/install.sh && source /etc/profile &> /dev/null

iptables -I INPUT -p tcp --dport 9999 -j ACCEPT   #如果开不了网页要放行端口

Clash管理地址(将IP替换成自己服务器IP):http://192.168.1.1:9999/ui

4 安装Miniconda

bash 复制代码
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh

按照提示完成安装:

Enter 阅读许可协议。

输入 yes 接受许可协议。

选择安装路径(默认路径为 ~/miniconda3)。

输入 yes 初始化 Miniconda。

bash 复制代码
source ~/.bashrc  #激活 Conda
conda --version   #检查 Conda 是否安装成功

conda list
conda create -n myenv python=3.9

rm -rf ~/miniconda3   #卸载 Miniconda

5 安装 Git, 方法从github里拉文件

bash 复制代码
sudo apt install git

有时会提示:

已安装 gitlab-jh 软件包 post-installation 脚本 子进程返回错误状态 1 在处理时有错误发生: gitlab-jh

原因是系统里残留的 gitlab-jh 包阻塞了 apt,使安装或更新 git 时报错。

解决方案就是 移除 gitlab-jh,保持系统干净:

bash 复制代码
sudo dpkg --remove --force-remove-reinstreq gitlab-jh
sudo apt autoremove

git --version 查看安装是否正常

6 安装docker

bash 复制代码
sudo apt install apt-transport-https ca-certificates curl software-properties-common  #更新你的包列表并安装一些必要的包
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -  #添加 Docker 的官方 GPG 密钥
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" #添加 Docker 的存储库
sudo apt install docker-ce   #安装 Docker

参考:

https://blog.csdn.net/m0_57236802/article/details/131818211

7 安装 dify

bash 复制代码
git clone https://github.com/langgenius/dify.git
cd dify/docker
cp .env.example .env
docker compose up -d

有的提示80 ,443端口被占用:

改一下 .env文件:

bash 复制代码
EXPOSE_NGINX_PORT=8081
EXPOSE_NGINX_SSL_PORT=4431

这里很有意思的是,它也提示443端口也被占用:

一起改了, 再运行:

bash 复制代码
docker compose up -d
bash 复制代码
有问题可以link q:316853809
相关推荐
lichenyang4535 小时前
Docker 学习笔记(五):Docker Compose,用一个 YAML 启动前端、后端和 MongoDB
docker
lichenyang4535 小时前
Docker 学习笔记(四):Dockerfile,把项目打成自己的镜像
docker·容器
lichenyang4535 小时前
Docker 学习笔记(三):Docker 网络、bridge、子网和容器互通
docker·容器
lichenyang4535 小时前
Docker 学习笔记(二):docker run 的参数到底在控制什么?
docker·容器
XIAOHEZIcode6 小时前
Ubuntu 终端美化全栈指南:Bash 到 Kitty 踩坑实录
linux·ubuntu·命令行
Patrick_Wilson5 天前
从「改个端口」到 502:Next.js on k8s 的容器端口、Service 映射与 env 覆盖
docker·kubernetes·next.js
Suroy5 天前
DockerView-Go:用 Go 写一个终端 Docker 监控工具,顺便做了个 Web 仪表盘
docker
云恒要逆袭5 天前
运行你的第一个Docker容器
后端·docker·容器
宋均浩6 天前
# Docker 镜像瘦身实战:从 1.2G 到 80MB 的五个优化步骤
ci/cd·docker
程序员老赵7 天前
10 分钟部署 OpenCode:Docker 一键安装,浏览器打开就能用 AI 写代码(附完整命令与排错)
docker·容器·ai编程