-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
75 lines (60 loc) · 4.36 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# 刷新组权限:
newgrp docker
# 构建基础镜像
docker build -t project-base:latest -f shared/Dockerfile.base .
# 构建和运行服务,应自动构建所有服务的镜像并启动容器 # 因为有插件(docker compose version)所以不用docker-compose而是docker compose
docker compose up --build
# 如果成功启动,查看运行中的容器,且可以获取ID。-a 参数可查看所有容器,包括已停止的
docker ps
# 单独启动并测试simcse_api服务
docker build -t simcse-api ./apis/simcse_api
docker run -p 5001:5000 simcse-api
# 测试网关服务
curl -X POST http://localhost:8000/simcse/rank_sentences \
-H "Content-Type: application/json" \
-d '{"fulltext": "This is the first sentence. This is the second sentence."}'
# 如 SimCSE API服务被单独启动(见行8-10),使用 curl 直接测试对应端口
curl -X POST http://localhost:5001/rank_sentences \
-H "Content-Type: application/json" \
-d '{"fulltext": "This is the first sentence. This is the second sentence."}'
# 如果某个服务无法正常工作,使用以下命令查看其日志
# docker logs <container_id>
# 停止所有正在运行的容器,停止所有由当前 docker-compose.yml 文件管理的容器,并删除对应的网络。不会删除镜像和数据卷
docker compose down
# 删除某容器
# docker rm <container_id>
# 删除所有停止的容器
docker container prune
# 列出所有镜像,查看哪些是项目相关的
docker images
# 删除某镜像
# docker rmi <image_id>
# 删除所有未被使用的镜像(无容器关联的镜像)
docker image prune
# Docker 数据卷用于持久化数据,但如果你的项目没有使用数据卷,清理它们可以释放空间
# 列出所有数据卷
docker volume ls
# 删除未被使用的数据卷
docker volume prune
# 清理docker-compose的专属网络
# 列出所有网络
sudo docker network ls
# 删除未使用的网络
sudo docker network prune
# 一键清理未使用的资源
sudo docker system prune -a
############################################################################
# 1 构建
docker compose build --no-cache # --no-cache 可以确保每一步都重新拉取或构建,不使用任何层缓存,从而真正“干净”地构建镜像。
# 2 手动启动有GPU需求的部分,如simcse_api
# 需要确保docker-compose.yml文件中的simcse_api有指定镜像名image: simcse_api:1.0
# --name指定一个容器的自定义名称,不然会变成系统默认名
docker run -d --gpus all -p 5002:5000 --name simcse_gpu_run simcse_api:1.0
docker run -d --gpus all -p 5003:5000 --name presumm_gpu_run presumm_api:1.0
# 3 Compose启动 - 无GPU需求部分,如gateway。 -d代表后台运行
docker compose up -d gateway
# simcse_api测试
curl -v -H "Content-Type: application/json" -d '{"text_list":["Hello world. This is a test. Another sentence.", "This should be in the batch 2. And this is another sentence in batch 2."], "batch":1}' http://localhost:5002/simcse/nltk_sentence_tokenize
curl -v -H "Content-Type: application/json" -d '{"fulltext":"Hello world. This is a test. Another sentence."}' http://localhost:5002/simcse/rank_sentences
curl -v -H "Content-Type: application/json" -d '{"fulltext":"Hello world. This is a test. Another sentence."}' http://localhost:5002/simcse/nltk_sentence_tokenize
curl -v -H "Content-Type: application/json" -d '{"fulltext":"The tomb of Kha and Merit is the funerary chapel and burial place of the ancient Egyptian foreman Kha and his wife Merit, in the northern cemetery of the workmen's village of Deir el-Medina. Kha supervised the workforce who constructed royal tombs during the reigns of the pharaohs Amenhotep II, Thutmose IV and Amenhotep III in the mid–Eighteenth Dynasty of the early New Kingdom of Egypt. He died in his 60s, while Merit died before him in her 20s or 30s. The couple's pyramid-shaped chapel has been known since at least 1818. The tomb was cut into the base of the cliffs. This position allowed the entrance to be quickly buried by debris deposited by landslides and later tomb construction, hiding its location from ancient robbers. Almost all of the contents of the tomb were awarded to the excavators and were shipped to Italy soon after the discovery. They have been displayed in the Museo Egizio in Turin since their arrival, and an entire gallery is devoted to them."}' http://localhost:5002/simcse/rank_sentences