使用 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 未正确安装或未配置。
相关推荐
一碗白开水一20 小时前
【训练技巧】bash: conda: command not found:conda 没有适配环境
开发语言·conda·bash
buxiangshui_cd2 天前
Conda命令
开发语言·python·conda
DogDaoDao3 天前
【第 04 篇】列表与元组 —— 序列类型核心详解
人工智能·python·深度学习·神经网络·机器学习·conda·numpy
Kobebryant-Manba6 天前
安装cuda
pytorch·python·深度学习·conda·numpy
zlkingdom7 天前
Jetson Orin开发板,在conda环境中直接实现Pytorch的GPU加速
人工智能·pytorch·conda·随笔·jetson orin
战斗强7 天前
RTX 5090 Grounded-SAM-2 实时 RTSP 跟踪部署指南
python·conda
zhangfeng11339 天前
htc 中minconda 明明安装了 Python 3.10显示 python 3.8 因为 `conda activate` 没有真正切换成功
开发语言·python·conda
H Journey10 天前
python包和项目管理工具uv、conda介绍
python·conda·uv
hyunbar13 天前
卸载 conda(太大) 安装 miniconda
conda