之前在anaconda用pip下载package配置环境时,为了下载速度快把源网站(channel)的配置换成了清华源,但是用conda install nvidia/label/cuda-12.1.0::cuda-nvcc 安装nvcc就报错了
Channels:
- https://anaconda.org
- nvidia/label/cuda-12.1.0
- defaults
Platform: linux-64
Collecting package metadata (repodata.json): failed
UnavailableInvalidChannel: HTTP 404 NOT FOUND for channel nvidia/label/cuda-12.1.0 <https://mirrors.tuna.tsinghua.edu.cn/anaconda/nvidia/label/cuda-12.1.0>
The channel is not accessible or is invalid.
You will need to adjust your conda configuration to proceed.
Use `conda config --show channels` to view your configuration's current state,
and use `conda config --show-sources` to view config file locations.
意思是源网站访问不到(<https://mirrors.tuna.tsinghua.edu.cn/anaconda/nvidia/label/cuda-12.1.0>),解决方法是换网站,所有与channel相关的问题应该都可以通过修改conda配置文件.condarc解决,使用
conda config --show 命令可以查看该文件内容:
add_anaconda_token: True
add_pip_as_python_dependency: True
aggressive_update_packages:
- ca-certificates
- certifi
- openssl
allow_conda_downgrades: False
allow_cycles: True
allow_non_channel_urls: False
allow_softlinks: False
allowlist_channels: []
always_copy: False
always_softlink: False
always_yes: None
anaconda_upload: None
auto_activate_base: True
auto_stack: 0
auto_update_conda: True
bld_path:
changeps1: True
channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
channel_priority: flexible
channel_settings: []
channels:
- defaults
client_ssl_cert: None
client_ssl_cert_key: None
clobber: False
conda_build: {}
create_default_packages: []
croot: /home/Helen/miniconda3/conda-bld
custom_channels:
pkgs/main: https://mirrors.tuna.tsinghua.edu.cn/anaconda
pkgs/free: https://mirrors.tuna.tsinghua.edu.cn/anaconda
pkgs/r: https://mirrors.tuna.tsinghua.edu.cn/anaconda
pkgs/pro: https://mirrors.tuna.tsinghua.edu.cn/anaconda
pkgs/msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
custom_multichannels:
defaults:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
local:
debug: False
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
default_python: 3.9
default_threads: None
deps_modifier: not_set
dev: False
disallowed_packages: []
download_only: False
dry_run: False
enable_private_envs: False
env_prompt: ({default_env})
envs_dirs:
- /home/Helen/miniconda3/envs
- /home/Helen/.conda/envs
error_upload_url: https://conda.io/conda-post/unexpected-error
execute_threads: 1
experimental: []
extra_safety_checks: False
fetch_threads: 5
force: False
force_32bit: False
force_reinstall: False
force_remove: False
ignore_pinned: False
json: False
local_repodata_ttl: 1
migrated_channel_aliases: []
migrated_custom_channels: {}
no_lock: False
no_plugins: False
non_admin_enabled: True
notify_outdated_conda: True
number_channel_notices: 5
offline: False
override_channels_enabled: True
path_conflict: clobber
pinned_packages: []
pip_interop_enabled: False
pkgs_dirs:
- /home/Helen/miniconda3/pkgs
- /home/Helen/.conda/pkgs
proxy_servers: {}
quiet: False
register_envs: True
remote_backoff_factor: 1
remote_connect_timeout_secs: 9.15
remote_max_retries: 3
remote_read_timeout_secs: 60.0
repodata_fns:
- current_repodata.json
- repodata.json
repodata_threads: None
report_errors: None
restore_free_channel: False
rollback_enabled: True
root_prefix: /home/Helen/miniconda3
safety_checks: warn
sat_solver: pycosat
separate_format_cache: False
shortcuts: True
shortcuts_only: []
show_channel_urls: True
signing_metadata_url_base: None
solver: libmamba
solver_ignore_timestamps: False
ssl_verify: True
subdir: linux-64
subdirs:
- linux-64
- noarch
target_prefix_override:
trace: False
track_features: []
unsatisfiable_hints: True
unsatisfiable_hints_check_depth: 2
update_modifier: update_specs
use_index_cache: False
use_local: False
use_only_tar_bz2: False
verbosity: 0
verify_threads: 1
这些配置关键词中带channel的就是关于源的配置,其含义详见以下博客:
【Python】conda镜像配置,.condarc文件详解,channel镜像-CSDN博客
下载软件包时会去名为“channel”的参数内容找源网站,我这里是默认-defaults,所以会跳转到default_channels参数里去找网站,以下命令是在执行当前下载任务设定channel为某网址:
conda install package -c 网址
但是对我的问题没用,因为我的配置文件里设置了channel_alias参数(意思是索引package的前缀网址),这个参数的优先级高于channel,所以只要这个参数存在都会按照其内容去配置源网站,这是个非必须参数所以只要删除这个参数就行:
conda config --remove-key channel_alias
附上关于清华源配置的官方说明:anaconda | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
一些关于改写cuda配置文件的命令:
配置某参数:conda config --set auto_update_conda False
# 增加channel (以配置清华源为例)
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud//pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
设置搜索是显示通道地址: conda config --set show_channel_urls
删除channel:conda config --remove channels https://anaconda.org
删关键字: conda config --remove-key channel_alias