使用 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 未正确安装或未配置。
相关推荐
伞伞悦读7 天前
【第39期】Python 第三方包安装详解:pip、conda、requirements、版本锁定和镜像源
python·conda·pip
梦想不只是梦与想9 天前
环境管理:Conda 与 venv
python·conda·uv
梦想不只是梦与想11 天前
环境管理系统:Conda(一)
python·conda·环境隔离
Blockbuater_drug11 天前
Protenix: conda 环境部署、零基础安装
conda·开源模型·字节跳动·v2·蛋白结构预测·protenix
AlfredZhao12 天前
执行新项目 python 脚本前,先用 conda 建一个独立环境
conda
THe CHallEnge of THe BrAve16 天前
conda虚拟环境打包离线迁移
conda
basketball61621 天前
AI Infra 配置 Conda + CUDA + LibTorch + PyTorch 开发环境:解决版本漂移、编译报错的完整指南
人工智能·pytorch·conda·libtorch
公爵爱学习21 天前
无人机视觉识别前序-Linux-YOLO安装
python·yolo·计算机视觉·conda·无人机
长江后浪博客1 个月前
Conda环境下测试Intel NPU:Python版本如何选择?
开发语言·python·conda·openvino·intel npu
伞伞悦读1 个月前
【第12期】Windows 开发环境备份与恢复:软件、环境变量、Git、conda 和 Docker 卷完整方案
git·docker·conda