Skip to content

Commit 93c6e60

Browse files
committedMar 26, 2020
moving to python3 step 1. testEnvironment works
1 parent f357c28 commit 93c6e60

33 files changed

+92
-140
lines changed
 

‎DataCollection.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import copy
1717
import time
1818
import logging
19-
from stopwatch import stopwatch
19+
from DeepJetCore.stopwatch import stopwatch
2020
logger = logging.getLogger(__name__)
2121

2222

@@ -550,8 +550,7 @@ def generatorFunction(self):
550550
xout = data.transferFeatureListToNumpy()
551551
wout = data.transferWeightListToNumpy()
552552
yout = data.transferTruthListToNumpy()
553-
554-
553+
555554
if len(wout)>0:
556555
yield (xout,yout,wout)
557556
else:

‎TrainData.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def readIn(self,fileprefix,shapesOnly=False):
5959
def _maybeConvertToSimpleArray(self,a):
6060
if str(type(a)) == "<class 'DeepJetCore.compiled.c_simpleArray.simpleArray'>":
6161
return a
62-
elif str(type(a)) == "<type 'numpy.ndarray'>":
62+
elif str(type(a)) == "<type 'numpy.ndarray'>" or str(type(a)) == "<class 'numpy.ndarray'>":
6363
rs = np.array([])
6464
arr = simpleArray()
6565
arr.createFromNumpy(a, rs)

‎__init__.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,4 @@
1010
import tensorflow as tf
1111
sys.modules["keras"] = tf.keras
1212

13-
import matplotlib
14-
matplotlib.use('Agg')
15-
16-
__version__ = '2.3'
13+
__version__ = '3.0'

‎bin/batch_conversion.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/env python
1+
#!/bin/env python3
22

33
import os
44
import logging

‎bin/check_conversion.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#! /bin/env python
1+
#! /bin/env python3
22

33
from argparse import ArgumentParser
44
from pdb import set_trace

‎bin/convertDCtoNumpy.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# encoding: utf-8
33

44
from argparse import ArgumentParser

‎bin/convertFromSource.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# encoding: utf-8
33
'''
44

‎bin/convertPre2.0DCtoDC.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# encoding: utf-8
33
'''
44

‎bin/convertPre2.0TDtoTD.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# encoding: utf-8
33
'''
44

‎bin/convertToPB.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33

44
#script that takes model in .h5 format as input as spits out the graph format used in CMSSW

‎bin/convertToTF.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
import imp
44
try:

‎bin/createDataCollectionFromTD.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# encoding: utf-8
33

44

‎bin/createSubpackage.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# encoding: utf-8
33

44

‎bin/extractDjcCppInterface.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33

44
from argparse import ArgumentParser

‎bin/mergeDataCollections.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#! /bin/env python
1+
#! /bin/env python3
22

33
from argparse import ArgumentParser
44
from DeepJetCore.DataCollection import DataCollection

‎bin/mergeOrSplitFiles.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# encoding: utf-8
33
'''
44

‎bin/plotLoss.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33

44

‎bin/predict.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
from argparse import ArgumentParser
44

‎bin/prepare_for_deployment.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#! /bin/env python
1+
#! /bin/env python3
22

33
from argparse import ArgumentParser
44

‎bin/testEnvironment.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
print('importing tensorflow...')
44

@@ -29,7 +29,7 @@
2929
b = keras.layers.Dense(10)(a)
3030
model = keras.models.Model(inputs=a, outputs=b)
3131
model.compile(optimizer='adam',loss='mse')
32-
model.fit(x=features, y=truth, batch_size=100, epochs=20)
32+
model.fit(x=features, y=truth, batch_size=100, epochs=3)
3333

3434
print('loading DeepJetCore compiled library...')
3535

@@ -55,7 +55,7 @@
5555
cd {djc_base}/testing
5656
rm -rf batchExplode
5757
export PYTHONPATH=`pwd`:$PYTHONPATH
58-
python batch_explosion.py batchDC/dataCollection.djcdc batchExplode
58+
python3 batch_explosion.py batchDC/dataCollection.djcdc batchExplode
5959
'''.format(djc_base=djc_base)
6060
os.system(script)
6161

‎bin/validateData.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33

44

‎compiled/Makefile

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# location of the Boost Python include files and library
3-
PYTHON_INCLUDE = `python-config --includes`
4-
PYTHON_LIB=`python-config --libs`
3+
PYTHON_INCLUDE = `python3-config --includes`
4+
PYTHON_LIB=`python3-config --libs`
55

66

77
LINUXADD= #-Wl --export-dynamic
@@ -28,7 +28,7 @@ classdict.so: classdict.cxx
2828

2929

3030
%: to_bin/%.cpp libdeepjetcorehelpers.so classdict.cxx
31-
g++ $(CFLAGS) -I./interface $(LINUXADD) $(PYTHON_INCLUDE) $< -L. -ldeepjetcorehelpers -lquicklz $(PYTHON_LIB) -lboost_python -lboost_numpy $(ROOTCFLAGS) $(ROOTSTUFF) -o $@
31+
g++ $(CFLAGS) -I./interface $(LINUXADD) $(PYTHON_INCLUDE) $< -L. -ldeepjetcorehelpers -lquicklz $(PYTHON_LIB) -lboost_python3 -lboost_numpy3 $(ROOTCFLAGS) $(ROOTSTUFF) -o $@
3232
mv $@ ../bin/
3333

3434
#helpers
@@ -40,10 +40,10 @@ obj/%.o: src/%.cpp
4040

4141
#pack helpers in lib
4242
libdeepjetcorehelpers.so: $(OBJ_FILES)
43-
g++ -o $@ -shared -fPIC $(LINUXADD) -fPIC obj/*.o $(ROOTSTUFF) $(PYTHON_LIB) -lboost_python -lboost_numpy
43+
g++ -o $@ -shared -fPIC $(LINUXADD) -fPIC obj/*.o $(ROOTSTUFF) $(PYTHON_LIB) -lboost_python3 -lboost_numpy3
4444

4545
%.so: %.o libdeepjetcorehelpers.so libquicklz.so
46-
g++ -o $(@) -shared -fPIC $(LINUXADD) $< $(ROOTSTUFF) -L./ -lquicklz $(PYTHON_LIB) -lboost_python -lboost_numpy -L./ -ldeepjetcorehelpers
46+
g++ -o $(@) -shared -fPIC $(LINUXADD) $< $(ROOTSTUFF) -L./ -lquicklz $(PYTHON_LIB) -lboost_python3 -lboost_numpy3 -L./ -ldeepjetcorehelpers
4747

4848
%.o: src/%.C
4949
g++ $(ROOTCFLAGS) -O2 -I./interface $(PYTHON_INCLUDE) -fPIC -c -o $(@) $<

‎conversion/conversion.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
try:
2+
import datastructures
23
from datastructures import *
34
except ImportError:
45
print('datastructure modules not found. Please define a DeepJetCore submodule')

‎docker/Dockerfile

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11

2-
FROM cernml4reco/djcbase:py2_latest
2+
FROM cernml4reco/djcbase:devpy3
3+
4+
5+
6+
################################################################################
7+
# Tensorflow
38

49
RUN export DEBIAN_FRONTEND=noninteractive && \
5-
pip --no-cache-dir install tensorflow-gpu==2.1 && \
6-
cd /usr/local/lib/python2.7/dist-packages/tensorflow_core/include/third_party && \
7-
mkdir gpus && \
8-
cd gpus && \
9-
ln -s /usr/local/cuda cuda
10-
11-
## torch/jupyter stuff
12-
RUN pip install torch future gensim jupyter prompt-toolkit seaborn
10+
pip3 --no-cache-dir install tensorflow-gpu==2.2.0-rc1
1311

14-
EXPOSE 8888
15-
1612

1713

14+
#RUN cd /usr/local/lib/python3.6/dist-packages/tensorflow_core/include/third_party && \
15+
# mkdir gpus && \
16+
# cd gpus && \
17+
# ln -s /usr/local/cuda cuda
18+
19+
20+
1821
################################################################################
1922
# the actual DeepJetCore. Make sure this gets built every time
2023

‎docker/Dockerfile_base

+32-73
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,28 @@ FROM nvidia/cuda:10.1-cudnn7-devel-ubuntu18.04
44

55
SHELL ["/bin/bash", "-c"]
66

7-
RUN apt-get update
8-
RUN apt-get install -y python2.7-dev python-pip nano emacs
9-
RUN apt-get install -y wget
10-
RUN apt-get install -y libboost-all-dev
11-
RUN apt-get install -y git
7+
RUN sed -i "s,# deb http://archive.canonical.com/ubuntu,deb http://archive.canonical.com/ubuntu,g" /etc/apt/sources.list && apt-get update --fix-missing
8+
9+
10+
#base
11+
RUN apt-get install -y python3.6-dev python3-pip
12+
RUN pip3 install --upgrade pip
13+
RUN ldconfig
14+
15+
#basic user tools
16+
RUN export DEBIAN_FRONTEND=noninteractive && \
17+
apt-get install -y git wget nano emacs \
18+
evince eog ffmpeg unzip zsh python3-tk locales \
19+
htop
20+
RUN apt-get update --fix-missing
1221

22+
RUN export DEBIAN_FRONTEND=noninteractive && \
23+
apt-get install -y krb5-user && \
24+
sed -i 's/default_realm = ATHENA.MIT.EDU/default_realm = CERN.CH/g' /etc/krb5.conf
25+
RUN apt-get update --fix-missing
1326

14-
## root part
27+
28+
############ root part
1529
RUN apt-get install -y libx11-dev libxpm-dev libxft-dev libxext-dev
1630
RUN apt-get install -y cmake
1731

@@ -32,78 +46,23 @@ RUN cd /temproot/build && \
3246

3347
#ensure import ROOT
3448
ENV PYTHONPATH="/usr/local/lib:${PYTHONPATH}"
49+
RUN ldconfig
3550

51+
############ END root part
3652

37-
RUN export DEBIAN_FRONTEND=noninteractive && \
38-
apt-get install -y python-tk
39-
RUN apt-get install -y locales
40-
41-
RUN pip install --upgrade pip
42-
43-
RUN pip install numpy
44-
RUN pip install root_numpy
45-
RUN pip install scikit-learn
46-
RUN pip install scikit-image
47-
RUN pip install h5py
48-
RUN pip install uproot Pillow scipy seaborn
49-
RUN pip install scikit-learn
50-
RUN pip install scikit-image
51-
RUN pip install matplotlib
52-
53-
#may be useful
54-
RUN pip install opencv-python
55-
RUN pip install easydict tqdm
56-
RUN pip install Cython
57-
RUN pip install numba
58-
59-
#already in the container from nvidia
60-
#RUN wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.1.243-1_amd64.deb &&\
61-
# dpkg -i cuda-repo-ubuntu1804_10.1.243-1_amd64.deb &&\
62-
# apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub &&\
63-
# apt-get update &&\
64-
# wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb &&\
65-
# apt install -y ./nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb &&\
66-
# apt-get update
67-
#
68-
#RUN export DEBIAN_FRONTEND=noninteractive && \
69-
# apt-get install -y --allow-downgrades --allow-change-held-packages --no-install-recommends \
70-
# cuda-10-1 \
71-
# libcudnn7=7.6.4.38-1+cuda10.1 \
72-
# libcudnn7-dev=7.6.4.38-1+cuda10.1
73-
#
74-
##will also get new cuda version
75-
#RUN export DEBIAN_FRONTEND=noninteractive && \
76-
# apt-get install -y --no-install-recommends libnvinfer6=6.0.1-1+cuda10.1 \
77-
# libnvinfer-dev=6.0.1-1+cuda10.1 \
78-
# libnvinfer-plugin6=6.0.1-1+cuda10.1
79-
80-
81-
RUN export DEBIAN_FRONTEND=noninteractive && \
82-
apt-get update --fix-missing
83-
84-
RUN export DEBIAN_FRONTEND=noninteractive && \
85-
apt-get install -y krb5-user && \
86-
sed -i 's/default_realm = ATHENA.MIT.EDU/default_realm = CERN.CH/g' /etc/krb5.conf
87-
88-
#for me ;)
89-
90-
RUN sed -i "s,# deb http://archive.canonical.com/ubuntu,deb http://archive.canonical.com/ubuntu,g" /etc/apt/sources.list
91-
92-
RUN apt-get update --fix-missing
93-
RUN apt-get install -y zsh
94-
95-
RUN apt-get install -y ffmpeg
96-
#not yet RUN apt-get install -y nvtop
53+
### boost
54+
RUN apt-get install -y libboost-all-dev
9755

98-
##gpu specific stuff
99-
RUN pip install gpustat
100-
RUN pip install setGPU
10156

57+
############ PIP packages
10258

103-
RUN apt-get install -y unzip
59+
RUN pip3 install --upgrade setuptools
60+
RUN pip3 install numpy root_numpy scikit-learn scikit-image h5py matplotlib uproot Pillow scipy seaborn
61+
RUN pip3 install opencv-python easydict tqdm Cython numba
10462

105-
RUN apt-get install -y evince eog
63+
RUN pip3 install gpustat setGPU
10664

65+
## torch/jupyter stuff
66+
RUN pip3 install torch future gensim jupyter prompt-toolkit
67+
EXPOSE 8888
10768

108-
RUN sed -i "s,# deb http://archive.canonical.com/ubuntu,deb http://archive.canonical.com/ubuntu,g" /etc/apt/sources.list
109-
RUN apt update

‎evaluation/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pdb import set_trace
55

66
#gather all the files here
7-
modules = [basename(i.replace('.py','')) for i in glob('%s/[A-Za-z]*.py' % dirname(__file__))]
7+
modules = ["DeepJetCore.evaluation."+basename(i.replace('.py','')) for i in glob('%s/[A-Za-z]*.py' % dirname(__file__))]
88
__all__ = []
99
structure_list=[]
1010
for module_name in modules:

‎preprocessing/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pdb import set_trace
55

66
#gather all the files here
7-
modules = [basename(i.replace('.py','')) for i in glob('%s/[A-Za-z]*.py' % dirname(__file__))]
7+
modules = ["DeepJetCore.preprocessing."+basename(i.replace('.py','')) for i in glob('%s/[A-Za-z]*.py' % dirname(__file__))]
88
__all__ = []
99
structure_list=[]
1010
for module_name in modules:

0 commit comments

Comments
 (0)