Help Center/ ModelArts/ Troubleshooting/ Training Jobs/ OBS Operation Issues/ What Do I Do If Error Message "No such file or directory" Is Displayed in Training Job Logs?
Updated on 2024-06-11 GMT+08:00

What Do I Do If Error Message "No such file or directory" Is Displayed in Training Job Logs?

When you use ModelArts, your data is stored in an OBS bucket. There is an OBS path to your data, for example, bucket_name/dir/image.jpg. ModelArts training jobs run in containers, and the jobs access OBS data through the OBS path to the data. If the file or path is unavailable, it is possible that the data storage path was incorrectly configured when you created the training job, or that the access path in the code file is incorrect.

Perform the following operations to locate the fault:

  1. Checking Whether the Affected Path Is an OBS Path
  2. Checking Whether the Affected Path Is Available

Checking Whether the Affected Path Is an OBS Path

When using ModelArts, store your data in an OBS bucket. However, the OBS path cannot be used to read data during the execution of the training code.

The reason is as follows:

After a training job is created, the training performance is poor if the running container is directly connected to OBS. To prevent this issue, the system automatically downloads the training data to the local path of the running container. Therefore, an error occurs if an OBS path is used in training code.

If the affected path is to the training data, perform the following operations to resolve this issue (see "Parsing Input and Output Paths" for details):

  1. When creating an algorithm, set the code path, which defaults to data_url, in the input path mapping configuration.
  2. Add a hyperparameter, which defaults to data_url, to the training code. Use data_url as the local path for inputting the training data.

Checking Whether the Affected Path Is Available

The code developed locally must be uploaded to the ModelArts backend. In training code, it is error-prone to set the path for storing the dependency file.

The following general solution is recommended: Use the OS API to obtain the absolute path of the dependency file.

Example:

|---project_root                # Root directory for code
   |---BootfileDirectory        # Directory where the boot file is located
     |---bootfile.py            # Boot file
   |---otherfileDirectory       # Directory of other dependency files
     |---otherfile.py           # Other dependency files
    

Do as follows to obtain the path of the dependency file, otherfile_path in this example, in the boot file:

import os
current_path = os.path.dirname(os.path.realpath(__file__)) # Directory where the boot file is located
project_root = os.path.dirname(current_path) # Root directory of the project, which is the code directory set on the ModelArts training console
otherfile_path = os.path.join(project_root, "otherfileDirectory", "otherfile.py")