You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encountered an issue while using the build-ubuntu.sh script to build Docker images. Despite the ${CPU_CORES} environment variable being set (via check-cpu.sh), CMake utilizes all available cores instead of respecting the specified number.
When check-cpu.sh is run independently, it correctly returns a value of 3. However, during the Docker build process, all cores are still used.
Is this the intended behavior?
Reproduction Steps:
Run check-cpu.sh independently and observe that it returns the expected number of cores.
Run build-ubuntu.sh and observe that CMake uses all available CPU cores instead of the value defined in ${CPU_CORES}.
Expected Behavior:
CMake should respect the ${CPU_CORES} value calculated by check-cpu.sh.
Relevant Code:
The issue appears to stem from the following lines:
RUN export CPU_CORES=`${AV_DEV}/docker/check-cpu.sh` && echo "Build multithreading number of cores: ${CPU_CORES}"
Proposed Fix:
To ensure the ${CPU_CORES} environment variable is properly calculated and used, I suggest rewriting the lines as:
RUN CPU_CORES=`${AV_DEV}/docker/check-cpu.sh`&& \
echo"Build multithreading number of cores: ${CPU_CORES}"&& \
echo"export CPU_CORES=${CPU_CORES}">> /etc/profile.d/alicevision.sh
This change will:
Execute the check-cpu.sh script to calculate the number of cores.
Log the value of CPU_CORES for visibility.
Persist the CPU_CORES variable if needed in later build steps by saving it to /etc/profile.d/cpu_cores.sh.
Next Steps:
If this is indeed an issue, I’m happy to submit a pull request with the proposed fix. If I am misunderstanding the intended behavior, please let me know, and I’ll close this report.
Thank you for your time and support!
Best regards, cewing
The text was updated successfully, but these errors were encountered:
Additional Issue: Environment Variables in /etc/profile.d/alicevision.sh Are Not Used in the Build Process
While investigating the original issue, I discovered that none of the environment variables written to /etc/profile.d/alicevision.sh are actually used during the build process.
The root cause is that Docker uses non-login shells for its RUN commands. As a result, the scripts in /etc/profile.d/ are not sourced during the build process. These scripts are only executed if the shell is a login shell, which is not the case for Docker’s default behavior.
Impact:
Environment variables written to /etc/profile.d/alicevision.sh are effectively ignored during Docker’s build steps and not availible in the future unless a login shell is specifically created.
Proposed Fix:
To ensure these environment variables are accessible during the build process, the relevant commands should be moved to use the ENV directive in the Dockerfile. For example:
ENV VAR_NAME=value
This approach guarantees that the environment variables are properly set and persist throughout the Docker build process.
Description:
I encountered an issue while using the
build-ubuntu.sh
script to build Docker images. Despite the${CPU_CORES}
environment variable being set (viacheck-cpu.sh
), CMake utilizes all available cores instead of respecting the specified number.When
check-cpu.sh
is run independently, it correctly returns a value of3
. However, during the Docker build process, all cores are still used.Is this the intended behavior?
Reproduction Steps:
check-cpu.sh
independently and observe that it returns the expected number of cores.build-ubuntu.sh
and observe that CMake uses all available CPU cores instead of the value defined in${CPU_CORES}
.Expected Behavior:
CMake should respect the
${CPU_CORES}
value calculated bycheck-cpu.sh
.Relevant Code:
The issue appears to stem from the following lines:
AliceVision/docker/Dockerfile_ubuntu_deps
Lines 73 to 74 in 303ff47
Proposed Fix:
To ensure the
${CPU_CORES}
environment variable is properly calculated and used, I suggest rewriting the lines as:This change will:
check-cpu.sh
script to calculate the number of cores.CPU_CORES
for visibility.CPU_CORES
variable if needed in later build steps by saving it to/etc/profile.d/cpu_cores.sh
.Next Steps:
If this is indeed an issue, I’m happy to submit a pull request with the proposed fix. If I am misunderstanding the intended behavior, please let me know, and I’ll close this report.
Thank you for your time and support!
Best regards,
cewing
The text was updated successfully, but these errors were encountered: