2. Utilice y ejecute su propio entorno de contenedor Docker Python.

Referencia del primer artículo:
https://blog.csdn.net/weixin_42357472/article/details/131953866

Ejecute un contenedor mientras ejecuta un comando o script

1) Esto es para abrir un entorno de contenedor de portátil jupyter externo.

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

Abrir localhost:8090 jumpter externamente requiere una contraseña de inicio de sesión

docker exec -it my_container bash

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

2) Ejecute el script

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"


Prueba, puedes ver que el registro de impresión es normal.

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,

Supongo que te gusta

Origin blog.csdn.net/weixin_42357472/article/details/131983275
Recomendado
Clasificación