跳转至

软件源介绍

介绍

  • 强烈推荐使用无忧云缓存高速下载源

一、pip(pypi)软件源

1.查看当前pip源Windows和linux适用:

pip config list

该命令会列出所有pip配置信息,包括当前使用的源地址。如果已配置镜像源,输出中会显示类似 global.index-url='https://pypi.tuna.tsinghua.edu.cn/simple'的内容。

2.全局修改pip源的方法:

方法一:使用命令行配置(推荐)

pip config set global.index-url https://nexus.idcai.com/repository/pypi.org/simple

方法二:手动编辑配置文件**

Windows系统:

配置文件路径:%APPDATA%\pip\pip.ini

文件内容修改为:

[global]
index-url = https://nexus.idcai.com/repository/pypi.org/simple
Linux系统:

配置文件路径:~/.pip/pip.conf~/.config/pip/pip.conf

文件内容修改为:

[global]
index-url = https://nexus.idcai.com/repository/pypi.org/simple

3.pip使用说明

全局使用pip源

配置了全局修改pip源可以直接使用pip install

pip install pytorch

临时使用pip源

临时针对这次安装使用强制指定某个源安装

pip install pytorch -i https://nexus.idcai.com/repository/pypi.org/simple

常用pip源列表:

源名称 源地址
pip无忧内网缓存源(强烈推荐超高速内网) https://nexus.idcai.com/repository/pypi.org/simple
pip官方源 https://pypi.org/simple
pip阿里云 https://mirrors.aliyun.com/pypi/simple
pip清华大学 https://pypi.tuna.tsinghua.edu.cn/simple
pip豆瓣 https://pypi.douban.com/simple
pip中国科学技术大学 https://pypi.mirrors.ustc.edu.cn/simple
pip华为云 https://repo.huaweicloud.com/repository/pypi/simple
pip腾讯云 https://mirrors.cloud.tencent.com/pypi/simple

二、conda更改软件源

1.通过命令行添加软件源

  • 查看当前 conda 源
conda config --show channels   # 如果输出包含 defaults,说明当前使用的是官方源。

更换国内 conda 源

  • 阿里云源

  • 设置基础选项

首先开启显示通道 URL 的功能:

conda config --set show_channel_urls yes
  1. 设置 Channel Alias (通道别名)

这是仓库的基础前缀地址:

conda config --set channel_alias https://nexus.idcai.com/repository/cuda_repo/
  1. 配置默认通道 (default_channels)

Conda 允许通过 append 或 add 来修改 default_channels 列表:

conda config --add default_channels https://nexus.idcai.com/repository/cuda_repo/pkgs/main
conda config --add default_channels https://nexus.idcai.com/repository/cuda_repo/pkgs/r
conda config --add default_channels https://nexus.idcai.com/repository/cuda_repo/pkgs/msys2
  1. 配置自定义通道 (custom_channels)

自定义通道需要逐个指定映射关系。注意最后两个(deepmodeling 和 nvidia)的 URL 略有不同:

  1. conda config --set custom_channels.conda-forge https://nexus.idcai.com/repository/cuda_repo/cloud conda config --set custom_channels.msys2 https://nexus.idcai.com/repository/cuda_repo/cloud conda config --set custom_channels.bioconda https://nexus.idcai.com/repository/cuda_repo/cloud conda config --set custom_channels.menpo https://nexus.idcai.com/repository/cuda_repo/cloud conda config --set custom_channels.pytorch https://nexus.idcai.com/repository/cuda_repo/cloud conda config --set custom_channels.pytorch-lts https://nexus.idcai.com/repository/cuda_repo/cloud conda config --set custom_channels.simpleitk https://nexus.idcai.com/repository/cuda_repo/cloud conda config --set custom_channels.deepmodeling https://nexus.idcai.com/repository/cuda_repo/cloud/ conda config --set custom_channels.nvidia https://mirrors.sustech.edu.cn/anaconda-extra/cloud

6.确认配置结果

执行完上述命令后,你可以通过以下命令查看是否配置正确:

conda config --show-sources

恢复默认源(官方源)

conda config --remove-key channels

2.全局修改conda源

通过修改 .condarc 文件更换 conda 源

.condarc 是 conda 的配置文件,直接编辑它可以灵活地管理软件源。

使用conda info命令

conda info

在输出的信息中查找"config file"字段,会显示当前使用的.condarc文件路径。

  • 无忧默认安装的Windows系统conda路径:C:\Anaconda3\.condarc
  • 无忧默认安装的Ubuntu系统conda路径:/opt/Anaconda3/.condarc
  • 如果文件不存在,可以自行创建

编辑.condarc文件,加入以下内容

  • conda无忧内网缓存源(强烈推荐超高速内网)
channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://nexus.idcai.com/repository/cuda_repo/pkgs/main
  - https://nexus.idcai.com/repository/cuda_repo/pkgs/r
  - https://nexus.idcai.com/repository/cuda_repo/pkgs/msys2
custom_channels:
  conda-forge: https://nexus.idcai.com/repository/cuda_repo/cloud
  msys2: https://nexus.idcai.com/repository/cuda_repo/cloud
  bioconda: https://nexus.idcai.com/repository/cuda_repo/cloud
  menpo: https://nexus.idcai.com/repository/cuda_repo/cloud
  pytorch: https://nexus.idcai.com/repository/cuda_repo/cloud
  pytorch-lts: https://nexus.idcai.com/repository/cuda_repo/cloud
  simpleitk: https://nexus.idcai.com/repository/cuda_repo/cloud
  deepmodeling: https://nexus.idcai.com/repository/cuda_repo/cloud/
  nvidia: https://mirrors.sustech.edu.cn/anaconda-extra/cloud
channel_alias: https://nexus.idcai.com/repository/cuda_repo/

常用conda源列表:

源名称 源地址
无忧内网缓存源(强烈推荐超高速内网) https://mirrors.tuna.tsinghua.edu.cn/anaconda/
conda官方源 https://repo.anaconda.com/
conda清华大学 https://mirrors.tuna.tsinghua.edu.cn/anaconda/
conda中国科学技术大学 https://mirrors.ustc.edu.cn/anaconda/

清除缓存并验证

conda clean -i  # 清除索引缓存
conda config --show channels  # 查看当前源

三、Ubuntu 软件源配置

修改支持任何版本

Ubuntu 的软件源配置文件位于 /etc/apt/sources.list。建议先备份原文件再进行修改。 配置步骤

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

修改配置文件: 编辑 /etc/apt/sources.list,将内容替换为:

# 获取ubuntu系统版本标识
RELEASE=$(cat /etc/os-release | grep VERSION_CODENAME | cut -d'=' -f2)

# !!!覆盖/etc/apt/sources.list
sudo cat > /etc/apt/sources.list << EOF
# 默认注释了源码仓库,如有需要可自行取消注释
deb https://nexus.idcai.com/repository/ubuntu.com/ubuntu/ "${RELEASE}" main restricted universe multiverse
# deb-src https://nexus.idcai.com/repository/ubuntu.com/ubuntu/ "${RELEASE}" main restricted universe multiverse

deb https://nexus.idcai.com/repository/ubuntu.com/ubuntu/ "${RELEASE}"-security main restricted universe multiverse
# deb-src https://nexus.idcai.com/repository/ubuntu.com/ubuntu/ "${RELEASE}"-security main restricted universe multiverse

deb https://nexus.idcai.com/repository/ubuntu.com/ubuntu/ "${RELEASE}"-updates main restricted universe multiverse
# deb-src https://nexus.idcai.com/repository/ubuntu.com/ubuntu/ "${RELEASE}"-updates main restricted universe multiverse

deb https://nexus.idcai.com/repository/ubuntu.com/ubuntu/ "${RELEASE}"-backports main restricted universe multiverse
# deb-src https://nexus.idcai.com/repository/ubuntu.com/ubuntu/ "${RELEASE}"-backports main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://nexus.idcai.com/repository/ubuntu.com/ubuntu/ "${RELEASE}"-proposed main restricted universe multiverse
# deb-src https://nexus.idcai.com/repository/ubuntu.com/ubuntu/ "${RELEASE}"-proposed main restricted universe multiverse
EOF

更新索引:

sudo apt update

四、Debian 软件源配置

修改支持任何版本

Debian 的配置文件同样位于 /etc/apt/sources.list。 配置步骤

sudo cp /etc/apt/sources.list.d/debian.sources /etc/apt/sources.list.d/debian.sources.bak
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

修改配置文件: 编辑 /etc/apt/sources.list,将内容替换为:

# 获取debian系统版本标识
RELEASE=$(cat /etc/os-release | grep VERSION_CODENAME | cut -d'=' -f2)

# !!!覆盖/etc/apt/sources.list
sudo cat > /etc/apt/sources.list << EOF
deb https://nexus.idcai.com/repository/debian.org/debian/ "${RELEASE}" main contrib non-free non-free-firmware
# deb-src https://nexus.idcai.com/repository/debian.org/debian/ "${RELEASE}" main contrib non-free non-free-firmware

deb https://nexus.idcai.com/repository/debian.org/debian/ "${RELEASE}"-updates main contrib non-free non-free-firmware
# deb-src https://nexus.idcai.com/repository/debian.org/debian/ "${RELEASE}"-updates main contrib non-free non-free-firmware

deb https://nexus.idcai.com/repository/debian.org/debian/ "${RELEASE}"-backports main contrib non-free non-free-firmware
# deb-src https://nexus.idcai.com/repository/debian.org/debian/ "${RELEASE}"-backports main contrib non-free non-free-firmware

# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
# deb https://security.debian.org/debian-security "${RELEASE}"-security main contrib non-free non-free-firmware
# deb-src https://security.debian.org/debian-security "${RELEASE}"-security main contrib non-free non-free-firmware
EOF

更新索引:

sudo apt update

五、Docker 软件源配置 (apt 仓库)

此步骤用于安装 Docker 引擎本身,需要添加 Docker 的官方 GPG 密钥并指向你的 Nexus 代理仓库。 配置步骤

# 1. 获取系统发行版标识 (ubuntu/debian) 和 版本代号 (focal/bullseye/etc.)
ID=$(grep -E '^ID=' /etc/os-release | cut -d'=' -f2 | tr -d '"')
RELEASE=$(grep -E '^VERSION_CODENAME=' /etc/os-release | cut -d'=' -f2 | tr -d '"')

# 如果 VERSION_CODENAME 为空(某些 Debian 版本),尝试从 VERSION_ID 获取
if [ -z "$RELEASE" ]; then
    RELEASE=$(grep -E '^VERSION=' /etc/os-release | sed -r 's/.* \((.*)\).*/\1/')
fi

# 2. 安装必要的基础工具
# 这里请先确定基础软件源
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg

# 3. 自动添加对应的 GPG 密钥
# 注意:这里路径根据 $ID 自动切换 debian 或 ubuntu
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://nexus.idcai.com/repository/docker-ce/linux/${ID}/gpg | sudo gpg --dearmor --yes -o /etc/apt/keyrings/docker.gpg

# 4. 自动写入软件源列表
# 这里的路径和代号全部参数化
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://nexus.idcai.com/repository/docker-ce/linux/${ID} \
  ${RELEASE} stable" | sudo tee /etc/apt/sources.list.d/docker.list 

安装 Docker:

sudo apt update &&  sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

六、Docker 镜像源

此配置用于加速 docker pull 拉取镜像的过程,修改的是 Docker 守护进程的配置。 配置步骤

编辑配置文件: 如果文件 /etc/docker/daemon.json 不存在则创建,添加以下内容:
{
  "registry-mirrors": [
    "https://nexus.idcai.com/repository/docker.io/"
  ]
}

常用docker源列表:

源名称 源地址
无忧内docker网缓存源(强烈推荐超高速内网) https://nexus.idcai.com/repository/docker.io/
1ms源 https://docker.1ms.run
daocloud源 https://docker.m.daocloud.io

重启 Docker 服务:

sudo systemctl daemon-reload
# 如果docker info没有看到更新的源,需要重启docker,注意这会重启所有容器!
# sudo systemctl restart docker
验证配置: 执行 docker info,在输出中查找 Registry Mirrors 部分,确认地址是https://nexus.idcai.com/repository/docker.io/

Hugging Face镜像源

建议您直接使用Hugging Face镜像站下载,速度快且稳定

Hugging Face镜像站地址:https://hf-mirror.com/

方法一:网页下载

请访问Hugging Face镜像站,在镜像站搜索,并在模型主页的Files and Version中下载文件。

方法二:huggingface-cli

huggingface-cli 是 Hugging Face 官方提供的命令行工具,自带完善的下载功能。

  1. 安装依赖
pip install huggingface_hub

2.设置环境变量

  • Linux
export HF_ENDPOINT=https://hf-mirror.com
# 设置你的token,详细怎么获取token,搜索google或者ai寻找帮助
$env HF_TOKEN = "hf_xxxxxxxxxxxxxxxxxxxxx"

建议写入到 ~/.bashrc

  • Windows Powershell
$env:HF_ENDPOINT = "https://nexus.idcai.com/repository/huggingface/"
# 设置你的token,详细怎么获取token,搜索google或者ai寻找帮助
$env:HF_TOKEN = "hf_xxxxxxxxxxxxxxxxxxxxx"

3.下载模型

hf download gpt2 --local-dir gpt2

4.下载数据集

hf download --repo-type dataset download wikitext --local-dir wikitext

可以添加 --local-dir-use-symlinks False 参数禁用文件软链接,这样下载路径下所见即所得,更多教程请访问Hugging Face镜像站查看

常用huggingface源列表:

源名称 源地址
无忧内huggingface网缓存源(强烈推荐超高速内网) https://nexus.idcai.com/repository/huggingface/
HF Mirror源 https://hf-mirror.com