codeshell安装配置

news2024/7/6 18:29:32

codeshell安装配置

  • 1 注意事项
    • 1.1 Python版本问题
  • 2 codeshell环境搭建
    • 2.1 codeshell使用软件各版本
    • 2.2 软件下载
    • 2.3 codeshell使用环境安装
      • 2.3.1 python-3.10.9-amd64.exe安装
      • 2.3.2 Anaconda3-2022.10-Windows-x86_64.exe安装
      • 2.3.3 创建环境
      • 2.3.4 Pytorch安装
      • 2.3.5 transformers
  • 3 下载codeshell模型
  • 4 codeshell使用
    • 注意:这里是在py310环境使用的,所以需要先激活py310环境。
    • 4.1 Web UI
    • 4.2 CLI Demo
  • 5 总结

1 注意事项

1.1 Python版本问题

codeshell推荐使用的python版本是3.8以上,但是最好不要选择最新版本的,否则可能会在配置pytorch环境时,报环境不兼容的错误。

这里使用目前最新版本python=3.12后,错误信息如下:

(py312) C:\Users\lc>conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia
Collecting package metadata (current_repodata.json): done
Solving environment: unsuccessful initial attempt using frozen solve. Retrying with flexible solve.
Solving environment: unsuccessful attempt using repodata from current_repodata.json, retrying with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: unsuccessful initial attempt using frozen solve. Retrying with flexible solve.
Solving environment: |
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
failed

UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:

Specifications:

  - torchaudio -> python[version='>=2.7,<2.8.0a0|>=3.5,<3.6.0a0']
  - torchaudio -> python[version='>=3.10,<3.11.0a0|>=3.11,<3.12.0a0|>=3.9,<3.10.0a0|>=3.8,<3.9.0a0|>=3.7,<3.8.0a0|>=3.6,<3.7.0a0']
  - torchvision -> python[version='>=3.10,<3.11.0a0|>=3.8,<3.9.0a0|>=3.9,<3.10.0a0|>=3.11,<3.12.0a0|>=3.7,<3.8.0a0|>=3.6,<3.7.0a0|>=3.5,<3.6.0a0']

Your python: python=3.12

If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.

The following specifications were found to be incompatible with each other:

Output in format: Requested package -> Available versions

Package pytorch-cuda conflicts for:
torchvision -> pytorch==2.1.0 -> pytorch-cuda[version='>=11.6,<11.7|>=11.7,<11.8|>=11.8,<11.9|>=12.1,<12.2']
torchaudio -> pytorch==2.1.0 -> pytorch-cuda[version='>=11.6,<11.7|>=11.7,<11.8|>=11.8,<11.9|>=12.1,<12.2']
torchaudio -> pytorch-cuda[version='11.6.*|11.7.*|11.8.*|12.1.*']
torchvision -> pytorch-cuda[version='11.6.*|11.7.*|11.8.*|12.1.*']

Package setuptools conflicts for:
python=3.12 -> pip -> setuptools
pytorch -> jinja2 -> setuptools
torchvision -> setuptools

Package flit-core conflicts for:
torchvision -> typing_extensions -> flit-core[version='>=3.6,<4']
pytorch -> typing_extensions -> flit-core[version='>=3.6,<4']

Package pytorch conflicts for:
torchvision -> pytorch[version='1.10.0|1.10.1|1.10.2|1.11.0|1.12.0|1.12.1|1.13.0|1.13.1|2.0.0|2.0.1|2.1.0|1.9.1|1.9.0|1.8.1|1.8.0|1.7.1|1.7.0|1.6.0|1.5.1']
torchaudio -> pytorch[version='1.10.0|1.10.1|1.10.2|1.11.0|1.12.0|1.12.1|1.13.0|1.13.1|2.0.0|2.0.1|2.1.0|1.9.1|1.9.0|1.8.1|1.8.0|1.7.1|1.7.0|1.6.0']

Package requests conflicts for:
torchvision -> requests
python=3.12 -> pip -> requests

2 codeshell环境搭建

codeshell地址:https://github.com/WisdomShell/codeshell

codeshell使用环境:

  1. python 3.8 and above【python 3.8以上】
  2. pytorch 2.0 and above are recommended【pytorch 建议2.0以上】
  3. transformers 4.32 and above【transformers 4.32以上】
  4. CUDA 11.8 and above are recommended (this is for GPU users, flash-attention users, etc.)【CUDA 11.8以上(可选)】

2.1 codeshell使用软件各版本

  1. python-3.10.9-amd64.exe【这里选择的是2022年的版本】
  2. Anaconda3-2022.10-Windows-x86_64.exe【用于安装管理Pytorch,这里选择的是2022年最后一个版本】
  3. Pytorch【根据实际情况而定】
  4. transformers【默认最新版】

2.2 软件下载

  1. python-3.10.9-amd64.exe
    • 下载地址:https://www.python.org/downloads
    • 选择如图所示下载

在这里插入图片描述
2. Anaconda3-2022.10-Windows-x86_64.exe
- 下载地址:清华开源镜像anaconda
- 选择如图所示下载在这里插入图片描述
3. Pytorch【非安装包的形式,不用下载】
4. transformers【非安装包的形式,不用下载】

2.3 codeshell使用环境安装

2.3.1 python-3.10.9-amd64.exe安装

  1. 选择自定义安装,并勾选使用管理员权限安装和将python.exe加入到环境。
    在这里插入图片描述
  2. 设置自定义安装位置
    在这里插入图片描述
  3. 验证安装结果
    • cmd命令弹窗,输入python ,点击回车,看到下图,则安装python成功。
      在这里插入图片描述

2.3.2 Anaconda3-2022.10-Windows-x86_64.exe安装

  1. 选择Just Me
    在这里插入图片描述
  2. 自定义安装路径
    在这里插入图片描述
  3. 只勾选Register,然后点击Install
    在这里插入图片描述
  4. 去除这两个勾选,然后点击Finish
    在这里插入图片描述

2.3.3 创建环境

1.查看Python版本
cmd打开命令行,输入python --version,查验python版本。
在这里插入图片描述
2. 打开Anaconda Prompt页面,输入指令conda create -n py310 python=3.10(这里每个人不一样,要根据查出来的版本做修改。)
在这里插入图片描述
3. 看见如下图的示例,表示环境创建完毕。
在这里插入图片描述
4. 最后conda activate py310激活环境,看到左下角改变为py310,代表进入该环境。
在这里插入图片描述
5. 其他命令
- 退出激活的环境,conda deactivate
- 查看虚拟环境列表,conda env list
- conda删除环境,conda remove -n需要删除的环境名 --all。

到这里,就代表anaconda的安装配置全部完成。

2.3.4 Pytorch安装

  1. conda配置
  • 更换镜像源地址,以下是清华大学镜像源地址:
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/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes
  • 把连接超时的时间设置成40s,读取超时的时间修改成100s
conda config --set remote_connect_timeout_secs 40
conda config --set remote_read_timeout_secs 100
  • 配置文件位置:C:\Users\liuch\.condarc
channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - defaults
show_channel_urls: true
remote_connect_timeout_secs: 40.0
remote_read_timeout_secs: 100.0

注意:需要把 - defaults删掉。

  1. 查看本机的CUDA版本
    cmd命令行输入nvidia-smi,在第一行最右边可以看到CUDA的版本号。
    在这里插入图片描述
  2. 点击进入Pytorch官网,然后下拉至如图所示位置,只需保证系统和电脑匹配,CUDA版本小于本机CUDA版本,调整结束后,复制红框中的指令。
    conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia
    

在这里插入图片描述
4. 打开Anaconda Prompt,激活py310环境(conda activate py310),然后粘贴上一步的指令,回车执行。
在这里插入图片描述
5. 如果报OpenSSL错误

(py310) C:\Users\liuch>conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia
Collecting package metadata (current_repodata.json): failed

CondaSSLError: OpenSSL appears to be unavailable on this machine. OpenSSL is required to
download and install packages.

Exception: HTTPSConnectionPool(host='conda.anaconda.org', port=443): Max retries exceeded with url: /pytorch/win-64/current_repodata.json (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))

可去 https://slproweb.com/products/Win32OpenSSL.html 下载安装包,注意最好下载Win64 OpenSSL v1.1.1w LightEXE,也就是低版本的,因为v3.x的安装后依旧报错。
在这里插入图片描述
6. 输入y确认,回车。
7. 等待安装直到左上角出现done【下载依赖较多,耗时较长】。
在这里插入图片描述
8. 输入pip list,查看安装了哪些包。
9. 输入python进入环境,输入import torch,无报错代表导入成功(这里要等待一段时间)。
10. 输入torch.cuda.is_available()查看torch是否可以使用显卡,True代表可以。
在这里插入图片描述
至此,Pytorch安装完毕。

2.3.5 transformers

安装最新版本:

pip install transformers

指定版本(推荐):

pip install transformers==4.34.0

输入pip list,查看安装了哪些包。
在这里插入图片描述
至此,codeshell环境安装完毕。

3 下载codeshell模型

在第二部分主要是搭建了codeshell使用环境,但是本地还没有最底层的模型文件,所以需要单独下载模型文件,才能真正使用codeshell

目前有四个开源的模型如下:

  • CodeShell BaseCodelShell底座模型,具有强大的代码基础能力。
  • CodeShell ChatCodelShell对话模型,在代码问答、代码补全等下游任务重性能优异。
  • CodeShell Chat 4bitCodelShell对话模型4bit量化版本,在保证模型性能的前提下内存消耗更小,速度更快。
  • CodeShell CPPCodelShell对话模型CPP版本,支持开发者在没有GPU的个人电脑中使用。注意,CPP版本同样支持量化操作,用户可以在最小内存为8G的个人电脑中运行CodelShell

其中有三个模型是在huggingface上托管:

  • WisdomShell/CodeShell-7B:对应CodeShell Base
  • WisdomShell/CodeShell-7B-Chat:对应CodeShell Chat
  • WisdomShell/CodeShell-7B-Chat-int4:对应CodeShell Chat 4bit

所以需要从huggingface上下载下来。

git lfs install
git clone https://huggingface.co/WisdomShell/CodeShell-7B-Chat

4 codeshell使用

注意:这里是在py310环境使用的,所以需要先激活py310环境。

conda activate py310

4.1 Web UI

通过下列命令启动Web服务,服务启动后,可以通过https://127.0.0.1:8000进行访问。

python demos/web_demo.py
  1. 如果报错提示缺少相关依赖模块,使用pip install +模块名称下载安装即可,例如报下错误:
(py310) E:\Python\codeshell>python demos/web_demo.py
Traceback (most recent call last):
  File "E:\Python\codeshell\demos\web_demo.py", line 28, in <module>
    import gradio as gr
ModuleNotFoundError: No module named 'gradio'

则需要安装相关依赖,然后重新启动:

pip install gradio
  1. 如果提示连接不上https://huggingface.co,需要开代理,或者将model下载到本地。

4.2 CLI Demo

python demos/cli_demo.py

5 总结

  1. 耗内存
    4.1 Web UI4.2 CLI Demo使用时,可以看到占用内存16943MB,即16.54GB。
    在这里插入图片描述

  2. 响应慢
    根据问题写代码时,很慢。

  3. 准确性 尚可

    1. golang语言实现,输入一个英文句子,反转句子中单词的顺序,但单词内的字符顺序不变,简单起见,标点符号和普通单词一样处理。
    package main
    
    import (
        "fmt"
        "strings"
    )
    
    func reverseWords(s string) string {
        words := strings.Fields(s)
        for i, j := 0, len(words)-1; i < j; i, j = i+1, j-1 {
            words[i], words[j] = words[j], words[i]
        }
        return strings.Join(words, " ")
    }
    
    func main() {
        s := "the weather is nice today."
        fmt.Println(reverseWords(s))
    }
    
    1. golang语言使用两个协程交替打印数字和字母。
    package main
    
    import (
        "fmt"
        "time"
    )
    
    func main() {
        // 创建两个协程
        go printNumber()
        go printLetter()
    
        // 阻塞,直到协程完成
        for {
            // 休眠一段时间
            time.Sleep(1 * time.Second)
        }
    }
    
    func printNumber() {
        for i := 0; i < 10; i++ {
            fmt.Printf("%d ", i)
            time.Sleep(1 * time.Second)
        }
    }
    
    func printLetter() {
        for i := 'a'; i < 'z'; i++ {
            fmt.Printf("%c ", i)
            time.Sleep(1 * time.Second)
        }
    }
    
  4. 其他
    未测

个人目前觉得在配置较高的电脑运行可能会比较流畅,个人使用体验不是很好。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1126424.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

C++中的多态以及如何实现多态(近万字图文详解)

C中的多态 1. 多态的概念1.1 概念 2. 多态的定义及实现2.1多态的构成条件&#xff08;重点&#xff09;2.2 虚函数2.3 虚函数的重写(重点)2.4 C11 override 和 final2.5 重载、覆盖(重写)、隐藏(重定义)的对比 3. 抽象类3.1 概念3.2 接口继承和实现继承 4. 多态的原理4.1虚函数…

MySQL1——喵喵期末不挂科

宝宝&#xff0c;你不点个赞吗&#xff1f;不评个论吗&#xff1f;不收个藏吗&#xff1f; 最后的最后&#xff0c;关注我&#xff0c;关注我&#xff0c;关注我&#xff0c;你会看到更多有趣的博客哦&#xff01;&#xff01;&#xff01; 喵喵喵&#xff0c;你对我真的很重要…

零代码编程:用ChatGPT多线程批量将PDF文档转换为word格式

pdf2docx是Python的一个库&#xff0c;可以很方便的将PDF文档转换为word格式&#xff0c;首先安装这个库。 然后在ChatGPT中输入提示词&#xff1a; 你是一个Python编程专家&#xff0c;要完成一个文档格式转换的任务&#xff0c;具体步骤如下&#xff1a; 打开F盘的Books文件…

FreeRTOS基础(如何学好FreeRTOS?)

目录 基础知识 进阶内容 后期“摆烂” 基础知识 实时操作系统 (RTOS)&#xff1a;FreeRTOS是一个实时操作系统&#xff0c;它提供了任务管理、调度和同步等功能&#xff0c;在嵌入式系统中有效地管理多个任务。 任务&#xff08;Task&#xff09;&#xff1a;任务是在RTOS…

祝所有的程序猿们2023年的1024节快乐~

许久没更新Bolg了&#xff0c;眼看就要到1024节&#xff0c;其实也是没有可以更新的东西&#xff0c;目前在PhD&#xff0c;发现很多东西都还需要慢慢沉淀&#xff0c;放一doctoral college 开学的时候ppt的老图。 越往深处研究会陷入泥潭&#xff0c;考虑的细节将会越来越多&…

如何在Ubuntu下安装RabbitMQ服务并异地远程访问?

文章目录 前言1.安装erlang 语言2.安装rabbitMQ3. 内网穿透3.1 安装cpolar内网穿透(支持一键自动安装脚本)3.2 创建HTTP隧道 4. 公网远程连接5.固定公网TCP地址5.1 保留一个固定的公网TCP端口地址5.2 配置固定公网TCP端口地址 前言 RabbitMQ是一个在 AMQP(高级消息队列协议)基…

【Gensim概念】03/3 NLP玩转 word2vec

第三部分 对象函数 八 word2vec对象函数 该对象本质上包含单词和嵌入之间的映射。训练后&#xff0c;可以直接使用它以各种方式查询这些嵌入。有关示例&#xff0c;请参阅模块级别文档字符串。 类型 KeyedVectors 1&#xff09; add_lifecycle_event(event_name, log_level2…

Web前端—Flex布局:标准流、浮动、Flex布局、综合案例(短视频首页解决方案)

版本说明 当前版本号[20231024]。 20231024初版 目录 文章目录 版本说明目录Flex布局01-标准流02-浮动基本使用产品区域布局HTML标签CSS样式 清除浮动场景搭建额外标签法单伪元素法双伪元素法overfow法 03-Flex布局Flex组成主轴对齐方式侧轴对齐方式修改主轴方向弹性伸缩比弹…

从昏暗到明亮—改善照明环境,提升编程效率

作为一名程序员博主&#xff0c;长时间写代码、写博客&#xff0c;对着电脑屏幕的生活方式已经渐渐成为了我的日常。 然而&#xff0c;这种生活方式却给我的眼睛带来了相当大的压力。每当一天的工作结束&#xff0c;我的眼睛总是感到干涩、疲劳&#xff0c;让我感到不舒适。&am…

S5PV210裸机(六):SD卡

本文主要探讨s5pv210的SD的相关知识。 存储 软盘、硬盘、光盘、CD、磁带:磁存储,读写慢、可靠性低 NandFlash、NorFlash:电存储,读写接口时序复杂,接口众多 SD卡、MMC卡、MicroSD、TF卡:统一外部封装和接口,SD兼容MMC标准 iNand、MoviNand、e…

正点原子嵌入式linux驱动开发——Linux MISC驱动

misc的意思是混合、杂项的&#xff0c;因此MISC驱动也叫做杂项驱动&#xff0c;也就是当板子上的某些外设无法进行分类的时候就可以使用MISC驱动。MISC驱动其实就是最简单的字符设备驱动&#xff0c;通常嵌套在platform总线驱动中&#xff0c;实现复杂的驱动&#xff0c;本章就…

Web APIS——第一天(下)

一、随机轮播图案例 <!DOCTYPE html> <html lang"en"><head><meta charset"UTF-8" /><meta http-equiv"X-UA-Compatible" content"IEedge" /><meta name"viewport" content"widthde…

JAVA多线程基础篇--守护线程(Daemon Thread)

1.概述 JAVA中的线程主要分为两类&#xff1a;用户线程&#xff08;User Thread&#xff09;和守护线程(Daemon Thread)。JAVA语言中无论是线程还是线程池&#xff0c;默认都是用户线程&#xff0c;因此用户线程也被称为普通线程。守护线程也被称之为后台线程、服务线程或精灵…

LeetCode977——有序数组的平方

LeetCode977——有序数组的平方 给你一个按 非递减顺序 排序的整数数组 nums&#xff0c;返回 每个数字的平方 组成的新数组&#xff0c;要求新数组也按 非递减顺序 排序。 输入&#xff1a;nums [-4,-1,0,3,10] 输出&#xff1a;[0,1,9,16,100] 解释&#xff1a;平方后&…

【ECS游戏架构】逻辑帧驱动带来的性能和即时性问题分析

1024水一篇~ 个人拙见&#xff0c;如有错误希望大佬拔刀纠正。 根据守望先锋在GDC会议上对ECS架构的描述&#xff0c;所有的系统(system)都是由逻辑帧驱动的&#xff1a;每帧遍历所有的system&#xff0c;并调用system的update()更新游戏世界的状态。 在实际应用中这可能会存…

缓存分片中的哈希算法与一致性哈希算法

什么是缓存分片 在高并发场景下&#xff0c;缓存往往成为了瓶颈。这时候&#xff0c;我们可以通过缓存数据分片的方式来解决问题。所谓缓存数据分片&#xff0c;就是将缓存数据按照一定的规则分成多个片段&#xff0c;每个片段由不同的缓存节点负责。这样做有两个好处&#xf…

广告掘金全自动挂机项目,单设备30+【软件脚本+技术教程】

广告掘金项目是一种越来越受欢迎的赚钱方式&#xff0c;它通过观看广告视频来获取收益。然而&#xff0c;手动观看每个广告视频可能会耗费大量时间和精力。为了简化操作并提升效率&#xff0c;我们可以利用全自动挂机脚本来完成这一任务。接下来&#xff0c;将为您介绍如何使用…

proxmox pve /dev/mapper/pve-root扩容

vgs3 pvs4 vgs5 lvs6 lvremove /dev/pve/data8 lvresize -l 100%FREE /dev/pve/root9 resize2fs /dev/mapper/pve-root 10 history

爆肝整理,Pytest+Allure+Jenkins自动化测试集成实战(图文详细步骤)

目录&#xff1a;导读 前言一、Python编程入门到精通二、接口自动化项目实战三、Web自动化项目实战四、App自动化项目实战五、一线大厂简历六、测试开发DevOps体系七、常用自动化测试工具八、JMeter性能测试九、总结&#xff08;尾部小惊喜&#xff09; 前言 1、简介 pytesta…

宝塔FTP提示:553 Can‘t open that file: Permission denied的解决方案

[2023-10-18 15:16] 无法传输文件 ‘D:\phpstudy_pro\WWW\lockgis\static\js\coordtransform.js’。Cant open output connection for file “ftp://iot.test.net/lockgis/static/js/coordtransform.js”. Reason: “553 Can’t open that file: Permission denied”. 原因分析…