Commit b5dbff2
authored
Fix build system and failures for linux (#68)
To build the image, run the following command in the root directory of
the project:
```bash
$ docker build -t chai-build-env . --platform="linux/amd64" --progress=plain
```
To make a volume for the container, use the following command:
```bash
$ docker volume create chai-vol
```
This volume part might not be necessary.
To run the container, use the following command:
```bash
$ docker run -it --platform="linux/amd64" --name chai-vm --hostname chai-vm --privileged --memory 2g --cpus 2 -v chai-vol chai-build-env
```
Then you may run the following:
```bash
root@chai-vm:/app# cd demos/torchtest
root@chai-vm:/app/demos/torchtest# mkdir build
root@chai-vm:/app/demos/torchtest# cd build
root@chai-vm:/app/demos/torchtest/build# cmake ..
root@chai-vm:/app/demos/torchtest/build# make
root@chai-vm:/app/demos/torchtest/build# ./MyProject
Input: [1, 3, 10, 10]
Output: [1, 3, 10, 10]
```
Locally, you can do
```bash
$ export Torch_DIR=<ChAI-root>/libtorch
$ cd demos/torchtest
$ mkdir build
$ cd build
$ cmake -DCMAKE_PREFIX_PATH=<ChAI-root>/libtorch/share/cmake ..
$ make
$ ./MyProject
Input: [1, 3, 10, 10]
Output: [1, 3, 10, 10]
```
# Current Status
Currently, you need to have a working installation of CMake, PyThon, and
Chapel to use ChAI.
## General build instructions
After cloning,
```bash
$ git clone https://github.com/chapel-lang/ChAI.git
$ cd ChAI
```
use CMake to build the project.
```bash
$ mkdir build
$ cd build
$ cmake -DCMAKE_BUILD_TYPE=Release ..
```
This will create a `build` directory and run CMake to generate the
necessary build files.
To test if the build environment is working, you can run the following
command:
```bash
$ make MyExample && make TorchTestBridge
$ ./MyExample
Hello, world!
a: ndarray([[ 0, 1, 2],
[ 3, 4, 5],
[ 6, 7, 8]],
shape = (3, 3),
rank = 2)
b: ndarray([[ 0, 1, 2],
[ 3, 4, 5],
[ 6, 7, 8]],
shape = (3, 3),
rank = 2)
c: ndarray([[15, 18, 21],
[42, 54, 66],
[69, 90, 111]],
shape = (3, 3),
rank = 2)
$ ./TorchTestBridge
Input: [1, 3, 10, 10]
Output: [1, 3, 10, 10]
```
The first command will compile the `MyExample` program, which is a
simple "Hello, world!" program that uses ChAI. The second command will
compile the `TorchTestBridge` program, which tests the PyTorch interop
functionality of ChAI.
See `docker-dev-run.md` for instructions on how to run the examples in a
Docker container. This is useful if either of these build steps fail on
your system.
You may also try
```bash
$ cd examples/vgg
$ python3 dump_weights.py
$ cd ../..
$ make vgg
$ ./vgg images/frog.jpg
VGG Example Directory: .../ChAI/examples/vgg
Loading labels from .../ChAI/examples/vgg/imagenet/LOC_synset_mapping.txt
Loaded 1000 labels.
Constructing VGG16 model.
Constructed VGG16 model.
Loading VGG16 model weights.
Loaded VGG16 model.
Read file: .../ChAI/build/images/frog.jpg with ext: jpg
imageData shape: (3, 720, 1280)
normalizedImageData shape: (3, 720, 1280)
inputImage shape: (size = 3, sizes = 3 720 1280)
For 'images/frog.jpg' the top 5 predictions are:
0: label=tree frog, tree-frog; confidence=27%
1: label=tailed frog, bell toad, ribbed toad, tailed toad, Ascaphus trui; confidence=8.2%
2: label=leafhopper; confidence=4.5%
3: label=leaf beetle, chrysomelid; confidence=1.9%
4: label=weevil; confidence=1.5%
```63 files changed
Lines changed: 1724 additions & 546 deletions
File tree
- bridge
- include
- lib
- util
- clib
- cmake
- deb
- demos
- torchtest_bridge
- torchtest
- video
- webcam_filter
- examples
- my_example
- torch_model_loading
- vgg
- models/vgg16
- lib
- test/tiny
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
97 | 51 | | |
98 | 52 | | |
99 | 53 | | |
| |||
151 | 105 | | |
152 | 106 | | |
153 | 107 | | |
| 108 | + | |
| 109 | + | |
154 | 110 | | |
155 | 111 | | |
156 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
157 | 123 | | |
158 | 124 | | |
159 | 125 | | |
160 | 126 | | |
161 | 127 | | |
162 | 128 | | |
163 | 129 | | |
| 130 | + | |
164 | 131 | | |
165 | 132 | | |
| 133 | + | |
166 | 134 | | |
167 | 135 | | |
168 | 136 | | |
| |||
204 | 172 | | |
205 | 173 | | |
206 | 174 | | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
214 | 188 | | |
215 | 189 | | |
216 | 190 | | |
| |||
220 | 194 | | |
221 | 195 | | |
222 | 196 | | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
227 | 201 | | |
228 | 202 | | |
229 | 203 | | |
| |||
293 | 267 | | |
294 | 268 | | |
295 | 269 | | |
| 270 | + | |
| 271 | + | |
296 | 272 | | |
297 | 273 | | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
2 | 5 | | |
3 | 6 | | |
4 | | - | |
5 | 7 | | |
| 8 | + | |
6 | 9 | | |
7 | 10 | | |
8 | 11 | | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
15 | 20 | | |
| 21 | + | |
16 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
17 | 32 | | |
18 | | - | |
19 | 33 | | |
20 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
21 | 41 | | |
22 | 42 | | |
23 | | - | |
24 | | - | |
25 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
26 | 46 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
31 | 79 | | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
0 commit comments