Adjust MMCV_MAX version in MDE-Toolbox to prevent version complaints
RUN sed -i "s/MMCV_MAX = '1.5.0'/MMCV_MAX = '1.8.0'/g" /mde_toolbox/depth/init.py
Install yapf to fix configuration printing bug
RUN pip install yapf==0.40.1
Replace memory hook in MMCV to fix GPU context issue
COPY patch/hooks_memory.py $CONDA_DIR/envs/isuor/lib/python3.9/site-packages/mmcv/runner/hooks/memory.py and get following error while building it: => ERROR [ 2/17] RUN rm /etc/apt/sources.list.d/cuda.list && apt-key del 7fa2af80 && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get instal 12.1s
[ 2/17] RUN rm /etc/apt/sources.list.d/cuda.list && apt-key del 7fa2af80 && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends wget && wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.0-1_all.deb && dpkg -i cuda-keyring_1.0-1_all.deb:
0.341 rm: cannot remove '/etc/apt/sources.list.d/cuda.list': No such file or directory
The error you're encountering during the Docker build process is due to the rm command trying to remove a file that doesn't exist in the base image. Specifically:
code
rm: cannot remove '/etc/apt/sources.list.d/cuda.list': No such file or directory
This causes the RUN command to fail, halting the build process. Let's address this issue and ensure your Dockerfile builds successfully.
Solution
1. Modify the rm Command to Handle Non-Existent Files
The simplest way to prevent the rm command from failing when the file doesn't exist is to use the -f (force) flag. This flag tells rm to ignore nonexistent files and never prompt.
Change this line:
dockerfile
rm /etc/apt/sources.list.d/cuda.list && \
To:
dockerfile
rm -f /etc/apt/sources.list.d/cuda.list && \
2. Review the Use of apt-key
It's important to note that apt-key is deprecated in newer versions of Ubuntu (including Ubuntu 22.04, which you're using). Instead of using apt-key, it's recommended to manage repository keys using the /etc/apt/trusted.gpg.d/ directory or other supported methods.
However, since you're installing the cuda-keyring, which should handle repository keys appropriately, you might not need to manually delete keys unless you have a specific reason.
3. Updated Dockerfile Snippet
Here's the revised portion of your Dockerfile with the suggested changes:
Consolidate RUN Commands: To optimize the Docker build process and reduce image size, consider consolidating multiple RUN commands into a single one where appropriate. This minimizes the number of layers in the final image.
Use .dockerignore: Ensure you have a .dockerignore file to exclude unnecessary files from the build context, which can speed up the build process.
Leverage Build Caching: Organize your Dockerfile to maximize the use of build cache. Place commands that change less frequently towards the top.
Stay Updated with Best Practices: Regularly review Docker's official best practices to ensure your Dockerfiles are optimized and secure.
Conclusion
By modifying the rm command to handle the absence of /etc/apt/sources.list.d/cuda.list gracefully, you resolve the immediate build error. Additionally, reviewing and updating deprecated commands like apt-key ensures your Dockerfile remains compatible with newer Ubuntu versions and follows current best practices.
If you encounter further issues or need more assistance with Dockerfile optimizations, feel free to ask!