Updated on 2024-06-11 GMT+08:00

Failed to Install a Third-Party Package

Symptom

  • How to install custom library functions for ModelArts, for example, apex.
  • The following error occurs when a third-party package is installed in the ModelArts training environment:
    xxx.whl is not a supported wheel on this platform

Possible Cause

Error xxx.whl is not a supported wheel on this platform occurs, because the format of the name of the installed file is not supported. For details about the solution, see 2.

Solution

  1. Installing the third-party package
    1. For an existing package in pip, run the following code to install it:
      import os
      os.system('pip install xxx')
    2. For a package that do not exist in pip, for example, apex, use the following method to upload the installation package to an OBS bucket. In this example, the installation package has been uploaded to obs://cnnorth4-test/codes/mox_benchmarks/apex-master/. Add the following code to the boot file to install the package:
      try:
          import apex
      except Exception:
          import os
          import moxing as mox
          mox.file.copy_parallel('obs://cnnorth4-test/codes/mox_benchmarks/apex-master/', '/cache/apex-master')
          os.system('pip --default-timeout=100 install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" /cache/apex-master')
  2. Installation error
    If the xxx.whl file fails to be installed, perform the following steps to solve the problem:
    1. If the xxx.whl file fails to be installed, add the following code to the boot file to check the file name and version supported by the pip command.
      import pip
      print(pip.pep425tags.get_supported())

      The supported file names and versions are as follows:

      [('cp36', 'cp36m', 'manylinux1_x86_64'), ('cp36', 'cp36m', 'linux_x86_64'), ('cp36', 'abi3', 'manylinux1_x86_64'), ('cp36', 'abi3', 'linux_x86_64'), ('cp36', 'none', 'manylinux1_x86_64'), ('cp36', 'none', 'linux_x86_64'), ('cp35', 'abi3', 'manylinux1_x86_64'), ('cp35', 'abi3', 'linux_x86_64'), ('cp34', 'abi3', 'manylinux1_x86_64'), ('cp34', 'abi3', 'linux_x86_64'), ('cp33', 'abi3', 'manylinux1_x86_64'), ('cp33', 'abi3', 'linux_x86_64'), ('cp32', 'abi3', 'manylinux1_x86_64'), ('cp32', 'abi3', 'linux_x86_64'), ('py3', 'none', 'manylinux1_x86_64'), ('py3', 'none', 'linux_x86_64'), ('cp36', 'none', 'any'), ('cp3', 'none', 'any'), ('py36', 'none', 'any'), ('py3', 'none', 'any'), ('py35', 'none', 'any'), ('py34', 'none', 'any'), ('py33', 'none', 'any'), ('py32', 'none', 'any'), ('py31', 'none', 'any'), ('py30', 'none', 'any')]
    2. Change faiss_gpu-1.5.3-cp36-cp36m-manylinux2010_x86_64.whl to faiss_gpu-1.5.3-cp36-cp36m-manylinux1_x86_64.whl, and run the following code to install the package:
      import moxing as mox
      import os
      
      mox.file.copy('obs://wolfros-net/zp/AI/code/faiss_gpu-1.5.3-cp36-cp36m-manylinux2010_x86_64.whl','/cache/faiss_gpu-1.5.3-cp36-cp36m-manylinux1_x86_64.whl')
      os.system('pip install /cache/faiss_gpu-1.5.3-cp36-cp36m-manylinux1_x86_64.whl')