WSL2 AI 环境搭建实录:Docker 与 Miniconda 配置
最近准备转行AI第一步就是需要稳定顺手的Linux环境。为了方便我直接使用Windows自带的WSL2。希望能帮助同样入门的朋友。1. 安装与配置 Docker安装 Docker#bash sudo apt update sudo apt install docker.io -y解决权限问题安装后执行 docker ps 报 permission denied需要将当前用户加入 docker 组#bash sudo groupadd docker sudo usermod -aG docker $USER注意 执行完后必须 exit 退出终端并重新进入 WSL权限才会生效。重新进入后执行 docker ps 不再报错。2. 解决 Docker 镜像拉取失败遇到的报错执行 docker run hello-world 时报错 dial tcp ... connection refused这是国内访问 Docker 官方镜像源不通导致的。解决方法创建并编辑 Docker 配置文件#bash sudo nano /etc/docker/daemon.json写入国内镜像源json { registry-mirrors: [ https://docker.m.daocloud.io, https://dockerproxy.com ] }保存退出后重启 Docker 服务#bash sudo systemctl restart docker再次执行 docker run hello-world成功拉取并运行。3. 实战部署 Nginx 容器运行 Nginx 容器并做端口映射#bash docker run -d -p 8000:80 nginx然后在 Windows 浏览器访问 http://127.0.0.1:8000成功看到 Nginx 欢迎页面。4. 安装 Miniconda 与换源下载并安装#bash wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh bash Miniconda3-latest-Linux-x86_64.sh安装过程中输入 yes 同意协议并初始化安装完成后 exit 退出重进执行 conda --version 成功显示版本号。配置国内镜像源#bash conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --set show_channel_urls yes pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple配置AI三剑客 numpy 负责数学计算pandas 负责表格数据matplotlib 负责画图因为刚才配了pip的清华源头所以下载速度比较快。pip install numpy pandas matplotlib
上一篇/下一篇内容由系统自动关联
返回资讯列表 →