You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Build_image.md 2.7 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. # Build image
  2. This part is the point, different project requirements need to rebuild the image. For a specific introduction to modelbox and the built-in functions of modelbox, please refer to the modelbox documentation manual.
  3. ## Container image download
  4. Use the following command to pull the relevant image. For example, cuda11.2, TensorFlow's unbuntu development image, then download the latest version of the image command is as follows:
  5. ```shell
  6. docker pull modelbox/modelbox-develop-tensorflow_2.6.0-cuda_11.2-ubuntu-x86_64:latest
  7. ```
  8. The address of the ModelBox image repository is as follows:https://hub.docker.com/u/modelbox
  9. ## One-click startup script
  10. ```shell
  11. #!/bin/bash
  12. # ssh map port, [modify]
  13. SSH_MAP_PORT=50022
  14. # editor map port [modify]
  15. EDITOR_MAP_PORT=1104
  16. # http server port [modify]
  17. HTTP_SERVER_PORT=8080
  18. # container name [modify]
  19. CONTAINER_NAME="modelbox_instance_`date +%s` "
  20. # image name
  21. IMAGE_NAME="modelbox/modelbox-develop-tensorflow_2.6.0-cuda_11.2-ubuntu-x86_64"
  22. HTTP_DOCKER_PORT_COMMAND="-p $HTTP_SERVER_PORT:$HTTP_SERVER_PORT"
  23. docker run -itd --gpus all -e NVIDIA_DRIVER_CAPABILITIES=compute,utility,video \
  24. --tmpfs /tmp --tmpfs /run -v /sys/fs/cgroup:/sys/fs/cgroup:ro \
  25. --name $CONTAINER_NAME -v /home:/home \
  26. -p $SSH_MAP_PORT:22 -p $EDITOR_MAP_PORT:1104 $HTTP_DOCKER_PORT_COMMAND \
  27. $IMAGE_NAME
  28. ```
  29. **Notes:**
  30. - After creating a file using the vim start_`docker.sh`, `i` enters the edit mode, pastes the above code, edits and modifications, and saves `wx`.
  31. - In the docker startup script, pay attention to whether the image version launched is consistent with the image version you need.
  32. - If you need to debug `gdb` in the container, you need to add the --privileged parameter to the startup container.
  33. - If you execute the above command on a machine without a `GPU`, you can delete the `--gpus`-related parameters. However, only CPU-related functional units can be used at this time.
  34. - If the port is not occupied but still unreachable after starting mirroring, you need to check the firewall settings.
  35. ## Use containers to fulfill requirements
  36. ```shell
  37. docker exec -it [container id] bash
  38. # Carry out your project.
  39. ```
  40. ## Build image
  41. 1. docker commit image
  42. Save project,It would be more convenient for us to just use `docker commit` directly.
  43. ```shell
  44. docker commit [container-ID] [image-name]
  45. ```
  46. 2. build image
  47. Use the image created
  48. ```dockerfile
  49. # load basic image
  50. FROM [image-name]
  51. # configure the Environment variable
  52. ENV PYTHONPATH "/root"
  53. # modify the Working directory
  54. WORKDIR /root
  55. ENTRYPOINT ["python"]
  56. ```
  57. Save the content as `Dockerfile`,command:
  58. ```shell
  59. docker build -t [image-name] .
  60. ```
  61. Get a image of our business needs.