-
Notifications
You must be signed in to change notification settings - Fork 531
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add scripts/documentation for VSCode setup with a docker dev image.
* Forks a subset of my shell functions into docker_shell_funcs.sh, specifically needed to create docker images that run as yourself. * Extends the readme with the three command bootstrap to get a dev container running. * Step by step instructions for configuring VSCode for Intellisense in either npcomp or LLVM. * Changes LLVM config options to enable tests. This setup is now suitable for upstream changes as well without rebuilding.
- Loading branch information
1 parent
ddc2e9d
commit 51d5124
Showing
6 changed files
with
197 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Build the docker images for npcomp: | ||
# npcomp:build-pytorch-1.6 | ||
# me/npcomp:build-pytorch-1.6 (additional dev packages and current user) | ||
function npcomp_docker_build() { | ||
if ! [ -f "docker/pytorch-1.6/Dockerfile" ]; then | ||
echo "Please run out of mlir-npcomp/ source directory..." | ||
return 1 | ||
fi | ||
echo "Building out of $(pwd)..." | ||
docker build docker/pytorch-1.6 --tag npcomp:build-pytorch-1.6 | ||
npcomp_docker_build_for_me npcomp:build-pytorch-1.6 | ||
} | ||
|
||
# Start a container named "npcomp" in the background with the current-user | ||
# dev image built above. | ||
function npcomp_docker_start() { | ||
local host_src_dir="${1-$HOME/src/mlir-npcomp}" | ||
if ! [ -d "$host_src_dir" ]; then | ||
echo "mlir-npcomp source directory not found:" | ||
echo "Pass path to host source directory as argument (default=$host_src_dir)." | ||
return 1 | ||
fi | ||
docker volume create npcomp-build | ||
docker run -d --rm --name "$container" \ | ||
--mount source=npcomp-build,target=/build \ | ||
--mount type=bind,source=$host_src_dir,target=/src/mlir-npcomp \ | ||
me/npcomp:build-pytorch-1.6 tail -f /dev/null | ||
} | ||
|
||
# Stop the container named "npcomp". | ||
function npcomp_docker_stop() { | ||
docker stop npcomp | ||
} | ||
|
||
# Get an interactive bash shell to the "npcomp" container. | ||
function npcomp_docker_login() { | ||
docker_execme -it npcomp /bin/bash | ||
} | ||
|
||
### Implementation helpers below. | ||
# From a root image, build an image just for me, hard-coded with a user | ||
# matching the host user and a home directory that mirrors that on the host. | ||
function npcomp_docker_build_for_me() { | ||
local root_image="$1" | ||
echo " | ||
FROM $root_image | ||
USER root | ||
RUN apt install -y sudo byobu git procps lsb-release | ||
RUN addgroup --gid $(id -g $USER) $USER | ||
RUN mkdir -p $(dirname $HOME) && useradd -m -d $HOME --gid $(id -g $USER) --uid $(id -u $USER) $USER | ||
RUN echo '$USER ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers | ||
USER $USER | ||
" | docker build --tag me/${root_image} - | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Deprecated PyTorch 1.3 based build | ||
|
||
These instructions are retained for the transition. Refer to top-level README for up to date instructions. | ||
|
||
### PyTorch 1.3 - ATen pseudo-device type dispatch | ||
|
||
The currently functional approach to PyTorch integration uses an ATen pseudo | ||
device for program capture. It is activated by including the PyTorch cmake | ||
path and settind `-DNPCOMP_ENABLE_TORCH_TYPE_DISPATCH=ON`. This approach has a | ||
very fragile dependency on a specific PyTorch revisions in the ~1.3 era and | ||
currently must be built via the docker image in `docker/pytorch-1.3`. | ||
|
||
We are migrating to newer approaches that build with more recent PyTorch | ||
versions, but these are not yet functional (see below). | ||
|
||
Docker container setup: | ||
|
||
```shell | ||
# One of the maintainers does periodically push new images. To use one of these, | ||
# skip the build step and use: | ||
# BUILD_IMAGE_TAG="stellaraccident/npcomp:build-pytorch-1.3" | ||
# Since we are not planning to support this branch long term, this process is | ||
# entirely ad-hoc at present and geared for project maintainers and build bots | ||
# to be able to make progress. | ||
# See https://hub.docker.com/repository/docker/stellaraccident/npcomp | ||
BUILD_IMAGE_TAG="local/npcomp:build-pytorch-1.3" | ||
|
||
# Build the docker image (rebuilds PyTorch, so takes quite some time). | ||
docker build docker/pytorch-1.3 --tag $BUILD_IMAGE_TAG | ||
|
||
# Docker workflow (or use your own preferences). | ||
# Create a volume for npcomp build artifacts. | ||
docker volume create npcomp-pytorch-1.3-build | ||
|
||
# Run the container, mounting /npcomp to the source directory and the volume | ||
# above to the /build directory. The source directory is mounted read-only to | ||
# avoid the container putting root owned files there. | ||
# Replace `$HOME/src/mlir-npcomp` with an appropriate path to where the project | ||
# is checked out. | ||
docker run \ | ||
--mount type=bind,source=$HOME/src/mlir-npcomp,target=/npcomp,readonly \ | ||
--mount source=npcomp-pytorch-1.3-build,target=/build \ | ||
--rm -it $BUILD_IMAGE_TAG /bin/bash | ||
``` | ||
|
||
```shell | ||
# From within the docker image. | ||
# Install MLIR and configure project. | ||
cd /npcomp | ||
BUILD_DIR=/build ./build_tools/install_mlir.sh | ||
BUILD_DIR=/build ./build_tools/cmake_configure.sh \ | ||
-DCMAKE_PREFIX_PATH=/opt/conda/lib/python3.6/site-packages/torch/share/cmake \ | ||
-DNPCOMP_ENABLE_TORCH_TYPE_DISPATCH=ON | ||
|
||
# Build. | ||
cd /build | ||
ninja | ||
ninja check-npcomp | ||
ninja check-frontends-pytorch | ||
``` |