Moss 安装环境准备
环境准备
* 一台GPU服务器
* Github 账号
* 安装 conda
购买GPU服务器
腾讯云秒杀页面:https://cloud.tencent.com/act/cps/redirect?redirect=35793&cps_key=559649b94a9171a54e0530cdc50d0cad
可以在秒杀页面购买GPU服务器 GN7-T4
,60元/15天
github 账号
由于我们 git clone
MOSS 代码的时候需要输入用户名和密码,如果没有账号,需要打开
github.com 网址注册一个账号,点击 [Sign up] 进入到注册页面
按照提示内容,输入相应的信息
创建Token
进入 token 页面 https://github.com/settings/tokens
- 为你创建的token添加描述
- 选择token有效期时间,可以选择永不过期
- 为token赋予权限。如果从命令行操作仓库,至少选中repo
点击生成。生成之后先复制下来,后面会用到
克隆一个仓库,提示输入用户名和密码,此处就可以使用上面生成的token作为密码使用。
$ git clone https://github.com/username/repo.git
Username: your_username
Password: your_token
安装 conda
wget https://repo.anaconda.com/archive/Anaconda3-2023.03-1-Linux-x86_64.sh
bash Anaconda3-2023.03-1-Linux-x86_64.sh
需要按下ENTER
回车键,查看许可证,直到提示是否接受许可内容,然后输入yes
按下ENTER
回车键 进行安装,输入 yes
来确认使用 conda init
来启动
为了使命令生效我们可以关不shell,重新连接
项目部署
下载本仓库内容至本地/远程服务器
git clone https://github.com/OpenLMLab/MOSS.git
cd MOSS
创建conda环境
conda create --name moss python=3.8
conda activate moss
安装依赖
pip install -r requirements.txt
网页Demo
streamlit run moss_web_demo_streamlit.py --server.port 8888
问题收集
TypeError: '<' not supported between instances of 'tuple' and 'float'
修改 models/custom_autotune.py
的 run
方法
def run(self, *args, **kwargs):
self.nargs = dict(zip(self.arg_names, args))
if len(self.configs) > 1:
key = tuple(args[i] for i in self.key_idx)
# This reduces the amount of autotuning by rounding the keys to the nearest power of two
# In my testing this gives decent results, and greatly reduces the amount of tuning required
if self.nearest_power_of_two:
key = tuple([2 ** int(math.log2(x) + 0.5) for x in key])
if key not in self.cache:
# prune configs
pruned_configs = self.prune_configs(kwargs)
bench_start = time.time()
timings = {config: self._bench(*args, config=config, **kwargs)
for config in pruned_configs}
temp = {}
for config in pruned_configs:
if isinstance(self._bench(*args, config=config, **kwargs),float):
continue
temp[config] = {self._bench(*args, config=config, **kwargs)}
bench_end = time.time()
self.bench_time = bench_end - bench_start
self.cache[key] = builtins.min(temp, key=timings.get)
self.hook(args)
self.configs_timings = timings
config = self.cache[key]
else:
config = self.configs[0]
self.best_config = config
if config.pre_hook is not None:
config.pre_hook(self.nargs)
return self.fn.run(*args, num_warps=config.num_warps, num_stages=config.num_stages, **kwargs, **config.kwargs)