--- title: 【记录】安装conda并更换清华源 urlname: -ji-lu--an-zhuang-conda-bing-geng-huan-qing-hua-yuan date: 2023-05-13 19:32:27 index_img: https://api.limour.top/randomImg?d=2023-05-13 19:32:27 tags: conda --- ## 安装下载工具 + [GitHub Proxy](https://ghproxy.com) | [file-proxy](https://github.com/zwc456baby/file-proxy) + 安装 [aria2](https://github.com/aria2/aria2/releases),并添加到环境变量Path + 安装 Aria2 Explorer [chrome浏览器拓展](https://chrome.google.com/webstore/detail/aria2-explorer/mpkodccbngfoacfalldjimigbofkhgjn) + 可以 `aria2c --enable-rpc` 配合 Aria2 Explorer 进行下载 ## 安装conda + 下载 miniconda:[清华镜像](https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda) | [官网](https://docs.conda.io/en/main/miniconda.html) + `conda config --set show_channel_urls yes` + (Windows) `notepad.exe $env:HOMEPATH/.condarc` + (Linux) `nano .condarc` 确保是 [清华镜像](https://mirrors.tuna.tsinghua.edu.cn/help/anaconda) ## 附加 修改 envs 位置 + `nano .condarc` 附加下面的配置项 ```config envs_dirs: - /home/jovyan/upload/envs ``` ## 常用命令示例 + 创建环境:`conda create -n llama -c conda-forge python -y` + 查看环境:`conda info --env` + 删除环境:`conda remove -n py36 --all` + 安装 conda 包:`conda install -n llama compilers make -c conda-forge -y` + 安装 pip 包:`conda run -n llama pip install llama-cpp-python[server] -i https://pypi.tuna.tsinghua.edu.cn/simple` + 清理缓存:`conda clean --all` + 安装 paddlepaddle:`conda install paddlepaddle-gpu==2.4.2 cudatoolkit=11.6 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/Paddle/ -c conda-forge` ## 创建新环境示例 + `conda create -n tts_edge python -c conda-forge` + `conda activate tts_edge` + `python -m pip install edge-tts -i https://pypi.tuna.tsinghua.edu.cn/simple` + `edge-tts --list-voices` + `edge-tts --voice zh-CN-XiaoxiaoNeural --text "你好!有什么我可以帮助你的吗?" --write-media hello.mp3 --write-subtitles hello.vtt` ## 回滚环境 ```bash conda list --revisions conda install --revision 0 ``` ## 使用mamba加速 ```bash conda create -n something_fuck -c conda-forge mamba conda activate something_fuck mamba install -c bioconda bcftools ``` ## 构建包 ```bash mamba create -n build -c conda-forge conda-build source activate build conda config --set anaconda_upload yes ``` ## 附加 win平台 + [w64devkit-fortran](https://github.com/skeeto/w64devkit/releases): 不支持nvcc + [VS BuildTools](https://visualstudio.microsoft.com/zh-hans/visual-cpp-build-tools): 生成工具、CMake; CRT、ATL、MFC的SDK ```powershell conda create -n llama libcublas cuda-toolkit git -c nvidia -c conda-forge conda activate llama cd D:\llama git clone --depth=1 -b master --single-branch https://github.com/ggerganov/llama.cpp.git # 修改 Makefile,添加 -I$(CONDA_PREFIX)/include 和 -L$(CONDA_PREFIX)/lib # git add . && git commit -m 'add conda Path' & "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\LaunchDevCmd.bat" %windir%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -NoExit -Command "& 'C:\Users\11248\miniconda3\shell\condabin\conda-hook.ps1' ; conda activate 'C:\Users\11248\miniconda3' " # git checkout . && git clean -xdf ```