Best practices: Set up a DeepSeek-OCR development environment using DevPod

Updated at:

This topic describes how to use the DevPod feature of FunModel to quickly launch a cloud-based GPU development environment. This environment is pre-configured with the DeepSeek-OCR model, its dependencies, and sample code. You can use this environment to validate model features, perform custom development, or run performance tests.

Preparations

Before you begin, make sure that you have an active Alibaba Cloud account and are logged on to the FunModel console.

  1. Switch to the new console: If you are using the old version, click New Console in the upper-right corner of the page.

  2. Complete authorization: When you log on for the first time, follow the on-screen instructions to grant permissions to a RAM role and complete other configurations.

Create a DevPod development environment

  1. In the FunModel console, click Custom Development, and then select Custom Environment.

  2. Configure development startup parameters:

    • Container Image:

      • Regions in China: serverless-registry.cn-hangzhou.cr.aliyuncs.com/functionai/deepseek-ocr:dev-20251022

      • Regions outside China: serverless-registry.ap-southeast-1.cr.aliyuncs.com/functionai/deepseek-ocr:dev-20251022

    • Model Name: Name the development environment. For example, deepseek-ocr-dev. This name is used as your workspace name and determines the storage path of the model file on NAS (/mnt/deepseek-ocr-dev).

    • Model Source > Model ID: deepseek-ai/DeepSeek-OCR.

    • Start Command and Listening Port: Keep the default settings.

    • Instance Type: Select Elastic Instance > GPU Compute-optimized.

      • Recommendation: To ensure that the model runs stably, select a GPU instance with at least 16 GB of GPU memory.

      • Cost note: The GPU instance is billed on a pay-as-you-go basis while the DevPod is running. This can be expensive. To save costs, shut down the development environment when it is not in use.

    • Role Name: Select AliyunFCDefaultRole.

  3. Launch the development environment:

    Click DevPod Development and Debugging.

Test the model in the development environment

After the environment starts, the VS Code Web IDE opens automatically.

  1. Validation environment

    • In the terminal at the bottom of the IDE, run the following commands to check if the environment is ready.

      # 1. Check if the GPU is available. A list of GPU information should appear.
      nvidia-smi
      
      # 2. Check if the model file is downloaded to NAS.
      # Replace deepseek-ocr-dev with the model name you set in the previous step.
      ls -l /mnt/deepseek-ocr-dev
      The model file is pre-downloaded to a NAS volume and stored in the /mnt/{name} path, where {name} is the Model Name that you specified during creation.
  2. Upload a test image

    • In the file browser on the left side of the IDE, navigate to the /workspace/DeepSeek-OCR/DeepSeek-OCR-master directory.

    • Right-click in this directory, select New Folder, and name it input.

    • Right-click the input folder, select Upload, and then select an image in JPG or PNG format from your local machine for recognition.

  3. Run the Hugging Face inference script

    • Modify the configuration file: Open the /workspace/DeepSeek-OCR/DeepSeek-OCR-master/DeepSeek-OCR-hf/run_dpsk_ocr.py file. Modify the model name and image path in the file.

    • Run inference: Run the following command in the terminal.

      cd /workspace/DeepSeek-OCR/DeepSeek-OCR-master/DeepSeek-OCR-hf/
      python run_dpsk_ocr.py

      After the command runs successfully, the text recognized from the image is displayed.

      To run the vLLM inference script, modify the values of MODEL_PATH, INPUT_PATH, and OUTPUT_PATH in the config.py file.

Manage the development environment and costs

  • Stop the environment: On the DevPod list page, click Shutdown to stop billing for the GPU.

  • Delete the environment: On the DevPod list page, use the Delete action to permanently delete the GPU instance.

Note

Stopping or deleting the environment does not affect the data on NAS. To delete the data, use the rm command with caution.

FAQ

Q: What should I do if the DevPod fails to start or remains in the "Creating" state for a long time?

A: Check the following: 1. Ensure that the required permissions have been granted to the RAM user. 2. Verify that your Alibaba Cloud account has no overdue payment. 3. Check if GPU resources are insufficient in the selected region. You can try to switch to another region or instance type and retry.

Q: Why do I get an error or a "command not found" message when I run nvidia-smi?

A: Make sure you selected a GPU Compute-optimized instance when you created the environment. If you selected this instance type and the error persists, try restarting the development environment from the console.

Q: Why did the model download fail, leaving the /mnt/{name} directory empty?

A: This can be caused by temporary network fluctuations or issues accessing the model community. To resolve this, try deleting the current DevPod and creating a new one.

Q: How can I install additional Python packages in the environment?

A: You can run the pip install <package_name> command in the Web IDE terminal.