3
3
# This script runs through the code in each of the python examples.
4
4
# The purpose is just as an integrtion test, not to actually train
5
5
# models in any meaningful way. For that reason, most of these set
6
- # epochs = 1.
6
+ # epochs = 1 and --dry-run .
7
7
#
8
8
# Optionally specify a comma separated list of examples to run.
9
9
# can be run as:
10
10
# ./run_python_examples.sh "install_deps,run_all,clean"
11
11
# to pip install dependencies (other than pytorch), run all examples,
12
12
# and remove temporary/changed data files.
13
- # Expects pytorch to be installed.
13
+ # Expects pytorch, torchvision to be installed.
14
14
15
15
BASE_DIR=` pwd` " /" ` dirname $0 `
16
16
EXAMPLES=` echo $1 | sed -e ' s/ //g' `
17
17
18
- if which nvcc ; then
19
- echo " using cuda"
20
- CUDA=1
21
- CUDA_FLAG=" --cuda"
22
- else
23
- echo " not using cuda"
24
- CUDA=0
25
- CUDA_FLAG=" "
26
- fi
18
+ USE_CUDA=$( python -c " import torchvision, torch; print(torch.cuda.is_available())" )
19
+ case $USE_CUDA in
20
+ " True" )
21
+ echo " using cuda"
22
+ CUDA=1
23
+ CUDA_FLAG=" --cuda"
24
+ ;;
25
+ " False" )
26
+ echo " not using cuda"
27
+ CUDA=0
28
+ CUDA_FLAG=" "
29
+ ;;
30
+ " " )
31
+ exit 1;
32
+ ;;
33
+ esac
27
34
28
35
ERRORS=" "
29
36
@@ -63,7 +70,7 @@ function dcgan() {
63
70
unzip ${DATACLASS} _train_lmdb.zip || { error " couldn't unzip $DATACLASS " ; return ; }
64
71
popd
65
72
fi
66
- python main.py --dataset lsun --dataroot lsun --classes $DATACLASS --niter 1 $CUDA_FLAG || error " dcgan failed"
73
+ python main.py --dataset lsun --dataroot lsun --classes $DATACLASS --niter 1 $CUDA_FLAG --dry-run || error " dcgan failed"
67
74
}
68
75
69
76
function fast_neural_style() {
@@ -92,12 +99,12 @@ function imagenet() {
92
99
93
100
function mnist() {
94
101
start
95
- python main.py --epochs 1 || error " mnist example failed"
102
+ python main.py --epochs 1 --dry-run || error " mnist example failed"
96
103
}
97
104
98
105
function mnist_hogwild() {
99
106
start
100
- python main.py --epochs 1 $CUDA_FLAG || error " mnist hogwild failed"
107
+ python main.py --epochs 1 --dry-run $CUDA_FLAG || error " mnist hogwild failed"
101
108
}
102
109
103
110
function regression() {
@@ -115,7 +122,7 @@ function snli() {
115
122
echo " installing 'en' model if not installed"
116
123
python -m spacy download en || { error " couldn't download 'en' model needed for snli" ; return ; }
117
124
echo " training..."
118
- python train.py --epochs 1 --no-bidirectional || error " couldn't train snli"
125
+ python train.py --epochs 1 --dev_every 1 -- no-bidirectional --dry-run || error " couldn't train snli"
119
126
}
120
127
121
128
function super_resolution() {
@@ -126,7 +133,7 @@ function super_resolution() {
126
133
function time_sequence_prediction() {
127
134
start
128
135
python generate_sine_wave.py || { error " generate sine wave failed" ; return ; }
129
- python train.py || error " time sequence prediction training failed"
136
+ python train.py --steps 2 || error " time sequence prediction training failed"
130
137
}
131
138
132
139
function vae() {
@@ -136,18 +143,38 @@ function vae() {
136
143
137
144
function word_language_model() {
138
145
start
139
- python main.py --epochs 1 $CUDA_FLAG || error " word_language_model failed"
146
+ python main.py --epochs 1 --dry-run $CUDA_FLAG || error " word_language_model failed"
140
147
}
141
148
142
149
function clean() {
143
150
cd $BASE_DIR
144
- rm -rf dcgan/_cache_lsun_classroom_train_lmdb dcgan/fake_samples_epoch_000.png dcgan/lsun/ dcgan/netD_epoch_0.pth dcgan/netG_epoch_0.pth dcgan/real_samples.png fast_neural_style/saved_models.zip fast_neural_style/saved_models/ imagenet/checkpoint.pth.tar imagenet/lsun/ imagenet/model_best.pth.tar imagenet/sample/ snli/.data/ snli/.vector_cache/ snli/results/ super_resolution/dataset/ super_resolution/model_epoch_1.pth word_language_model/model.pt || error " couldn't clean up some files"
151
+ rm -rf dcgan/_cache_lsun_classroom_train_lmdb \
152
+ dcgan/fake_samples_epoch_000.png dcgan/lsun/ \
153
+ dcgan/_cache_lsunclassroomtrainlmdb \
154
+ dcgan/netD_epoch_0.pth dcgan/netG_epoch_0.pth \
155
+ dcgan/real_samples.png \
156
+ fast_neural_style/saved_models.zip \
157
+ fast_neural_style/saved_models/ \
158
+ imagenet/checkpoint.pth.tar \
159
+ imagenet/lsun/ \
160
+ imagenet/model_best.pth.tar \
161
+ imagenet/sample/ \
162
+ snli/.data/ \
163
+ snli/.vector_cache/ \
164
+ snli/results/ \
165
+ super_resolution/dataset/ \
166
+ super_resolution/model_epoch_1.pth \
167
+ time_sequence_prediction/predict* .pdf \
168
+ time_sequence_prediction/traindata.pt \
169
+ word_language_model/model.pt || error " couldn't clean up some files"
145
170
146
171
git checkout fast_neural_style/images/output-images/amber-candy.jpg || error " couldn't clean up fast neural style image"
147
172
}
148
173
149
174
function run_all() {
175
+ # cpp
150
176
dcgan
177
+ # distributed
151
178
fast_neural_style
152
179
imagenet
153
180
mnist
0 commit comments