使用 Conda创建新的环境遇到的问题

下载速度很慢

1、更新

复制代码
conda update -n base -c defaults conda

2、清理缓存

复制代码
conda clean --all

解决方法

方法 1:关闭严格的渠道优先级
  1. 检查是否开启了严格渠道优先级:

    复制代码
    conda config --show channel_priority

    如果返回 strict,说明启用了严格的渠道优先级。

  2. 将渠道优先级改为 flexible

    复制代码

    复制代码
    conda config --set channel_priority flexible

安装tensorflow(2.0版本以上不区分cpu和gpu版)

1. 更换国内镜像源

在中国大陆,直接连接到官方 PyPI 服务器可能会导致超时问题,推荐使用国内镜像源。以下是清华镜像的安装命令:

复制代码
pip install tensorflow==2.6.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

你也可以将镜像源永久配置到 pip 的配置文件中:

复制代码

复制代码
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

2. 设置更长的超时时间

网络环境较差时,可以尝试增加超时时间:

复制代码
pip install tensorflow==2.6.0 --default-timeout=100 -i https://pypi.tuna.tsinghua.edu.cn/simple

在命令行中直接检测 TensorFlow 是否安装成功,可以使用以下步骤:


1. 激活虚拟环境

如果你安装 TensorFlow 时使用的是虚拟环境(例如 tensorf_env),请先激活环境

复制代码

复制代码
conda activate tensorf_env

2. 使用 Python 检测 TensorFlow

在命令行中运行以下命令:

复制代码

复制代码
python -c "import tensorflow as tf; print(tf.__version__)"
  • 如果显示 TensorFlow 的版本号(例如 2.6.0),则说明安装成功。
  • 如果有错误信息,则说明安装有问题。

3. 检测 GPU 支持(可选)

如果需要检查是否检测到 GPU,可以运行以下命令:

复制代码

复制代码
python -c "import tensorflow as tf; print('GPU is', 'available' if tf.config.list_physical_devices('GPU') else 'NOT AVAILABLE')"
  • 如果输出 GPU is available,则说明安装的 TensorFlow 支持 GPU,且成功检测到 GPU。
  • 如果输出 GPU is NOT AVAILABLE,可能是显卡驱动、CUDA 或 cuDNN 未正确安装或未配置。
相关推荐
王 富贵3 天前
Conda常用命令大全
windows·conda
慕无言4 天前
pycharm2024选择conda环境
conda
灯下夜无眠5 天前
conda打包环境上传spark集群
大数据·spark·conda
YuSun_WK6 天前
使用conda配置环境时遇到的问题
conda
Caven776 天前
【Linux 技巧】如何在登录时自动激活 Conda Base 环境
linux·运维·conda
梁辰兴7 天前
PyCharm使用了Conda的虚拟环境创建的的Python项目,下载库(包)到该项目的虚拟环境中
python·pycharm·conda·错误·异常·异常报错
qq_203769497 天前
在conda环境中使用jupyter
python·jupyter·conda
中科院提名者8 天前
Conda与Pip混用导致的“幽灵包”现象
conda·pip
Victory_orsh9 天前
Conda常用命令集锦
conda
努力还债的学术吗喽12 天前
ffmpeg离线安装到服务器:解决conda/sudo/无法安装的通用方案
服务器·ffmpeg·conda