mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-14 03:44:02 +08:00
fix: Allow custom user ID (#2334)
This commit is contained in:
1 parent
5eb83e8acd
commit
c599d0f3a1
2 files changed
+13
-4
No files matched your search
+4
-3
@@ -1,5 +1,6 @@
|
||||
ARG CUDA_VERSION=11.8.0
|
||||
ARG OS_VERSION=22.04
|
||||
ARG USER_ID=1000
|
||||
# Define base image.
|
||||
FROM nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${OS_VERSION}
|
||||
|
||||
@@ -99,7 +100,7 @@ RUN git clone --branch 3.8 https://github.com/colmap/colmap.git --single-branch
|
||||
rm -rf colmap
|
||||
|
||||
# Create non root user and setup environment.
|
||||
RUN useradd -m -d /home/user -g root -G sudo -u 1000 user
|
||||
RUN useradd -m -d /home/user -g root -G sudo -u ${USER_ID} user
|
||||
RUN usermod -aG sudo user
|
||||
# Set user password
|
||||
RUN echo "user:user" | chpasswd
|
||||
@@ -107,7 +108,7 @@ RUN echo "user:user" | chpasswd
|
||||
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
|
||||
|
||||
# Switch to new uer and workdir.
|
||||
USER 1000
|
||||
USER ${USER_ID}
|
||||
WORKDIR /home/user
|
||||
|
||||
# Add local user binary folder to PATH variable.
|
||||
@@ -154,7 +155,7 @@ RUN python3.10 -m pip install omegaconf
|
||||
ADD . /home/user/nerfstudio
|
||||
USER root
|
||||
RUN chown -R user /home/user/nerfstudio
|
||||
USER 1000
|
||||
USER ${USER_ID}
|
||||
|
||||
# Install nerfstudio dependencies.
|
||||
RUN cd nerfstudio && \
|
||||
|
||||
@@ -154,6 +154,15 @@ docker build \
|
||||
--file Dockerfile .
|
||||
```
|
||||
|
||||
The user inside the container is called 'user' and is mapped to the local user with ID 1000 (usually the first non-root user on Linux systems).
|
||||
If you suspect that your user might have a different id, override `USER_ID` during the build as follows:
|
||||
|
||||
```bash
|
||||
docker build \
|
||||
--build-arg USER_ID=$(id -u) \
|
||||
--file Dockerfile .
|
||||
```
|
||||
|
||||
### Using an interactive container
|
||||
|
||||
The docker container can be launched with an interactive terminal where nerfstudio commands can be entered as usual. Some parameters are required and some are strongly recommended for usage as following:
|
||||
@@ -187,7 +196,6 @@ docker run --gpus all -v /folder/of/your/data:/workspace/ -v /home/<YOUR_USER>/.
|
||||
- Paths on Windows use backslash '\\' while unix based systems use a frontslash '/' for paths, where backslashes might require an escape character depending on where they are used (e.g. C:\\\\folder1\\\\folder2...). Alternatively, mounts can be quoted (e.g. `-v 'C:\local_folder:/docker_folder'`). Ensure to use the correct paths when mounting folders or providing paths as parameters.
|
||||
- Always use full paths, relative paths are known to create issues when being used in mounts into docker.
|
||||
- Everything inside the container, what is not in a mounted folder (workspace in the above example), will be permanently removed after destroying the container. Always do all your tasks and output folder in workdir!
|
||||
- The user inside the container is called 'user' and is mapped to the local user with ID 1000 (usually the first non-root user on Linux systems).
|
||||
- The container currently is based on nvidia/cuda:11.8.0-devel-ubuntu22.04, consequently it comes with CUDA 11.8 which must be supported by the nvidia driver. No local CUDA installation is required or will be affected by using the docker image.
|
||||
- The docker image (respectively Ubuntu 22.04) comes with Python3.10, no older version of Python is installed.
|
||||
- If you call the container with commands directly, you still might want to add the interactive terminal ('-it') flag to get live log outputs of the nerfstudio scripts. In case the container is used in an automated environment the flag should be discarded.
|
||||
|
||||
Reference in new issue
Block a user