二、使用运行自己的docker python容器环境

第一篇参考:
https://blog.csdn.net/weixin_42357472/article/details/131953866

运行容器同时执行命令或脚本

1)这是打开一个对外的jupyter notebook容器环境

docker run -d --name my_container -p 8090:8888 mynewpythonimage jupyter notebook --allow-root --ip 0.0.0.0

在外部打开localhost:8090 jupter需要登录密码

docker exec -it my_container bash

 jupyter notebook  list   ##可以查看到token密码

2)运行脚本

docker run -d --name my_container -p 8090:8888 mynewpythonimage  python test.py

##执行多步骤命令写一行里
docker run -it --name my_container -p 8090:8888 mynewpythonimage /bin/bash -c "cd /path/to/work && python test.py"


测试,可以看到打印日志正常

docker run -t --rm -v C:\Users\loong\.cache\huggingface\hub\models--shibing624--text2vec-base-chinese\snapshots\630e1b28a8f537b660:/work -v D:\llm\FZ\:/data  -w /data mynewpythonimage:v2 python text_emd_test.py
########
  0%|                                                                                            | 0/20 [00:00<?, ?it/s]Asking to truncate to max_length but no maximum length is provided and the model has no predefined maximum length. Default to no truncation.
tensor([[-3.3404e-02, -4.2442e-01,  5.4961e-01,  8.5657e-01,  1.7167e-01,
         -4.3740e-01, -8.3924e-02,  3.4234e-01,  2.7073e-01, -1.9262e-01,
         -8.8354e-02,  7.6036e-01,  4.9334e-01,  4.2327e-02,  7.1428e-01,
         -5.7222e-02, -5.4974e-01,  6.4444e-01, -7.7579e-01, -3.5119e-01,

猜你喜欢

转载自blog.csdn.net/weixin_42357472/article/details/131983275
今日推荐