'Keras/TF parallelization dependent on machine and data size
I am calling TF model with following code:
def define_model_2D():
model = Sequential()
model.add( Conv2D(32, (3, 3), activation='relu', kernel_initializer='he_uniform', padding='same', input_shape=(inpLength, inpWidth, 1)))
model.add(Dropout(0.2))
model.add(MaxPooling2D((2, 2)))
model.add( Conv2D(64, (3, 3), activation='relu', kernel_initializer='he_uniform', padding='same') )
model.add(Dropout(0.3))
model.add(MaxPooling2D((2, 2)))
model.add(Flatten())
model.add(Dense(128, activation='relu', kernel_initializer='he_uniform', kernel_regularizer=l2(0.0001),))
model.add(Dropout(0.4))
model.add(Dense(1, activation='sigmoid'))
opt = Adam(learning_rate=0.0005)
model.compile(optimizer=opt, loss='mean_squared_error', metrics=['accuracy'])
return model
model = define_model_2D()
history = model.fit(trainX, trainY, epochs=5, batch_size=512, validation_data=(testX, testY), verbose=1)
I noticed that on local laptop machine this runs on all cores available, while on remote Azure VM it uses only 1 core. The problem exists also for smaller model (conv1D). But when I switch to smaller data used in simulation (e.g 25% from initial 1000000 rows) it DO parallelize on the VM. I tried the solutions from thread: How to run Keras on multiple cores?.
Both laptop and VM are Windows with latest Anaconda. Also both have 32GB ram. Some meaningful versions listed below:
anaconda custom py38_1
anaconda-client 1.9.0 py38haa95532_0
anaconda-navigator 2.1.1 py38_0
anaconda-project 0.10.2 pyhd3eb1b0_0
keras 2.4.3 pyhd8ed1ab_0 conda-forge
keras-applications 1.0.8 py_1 conda-forge
keras-preprocessing 1.1.2 pyhd8ed1ab_0 conda-forge
tensorboard 2.7.0 pyhd8ed1ab_0 conda-forge
tensorboard-data-server 0.6.0 py38haa244fe_1 conda-forge
tensorboard-plugin-wit 1.8.1 pyhd8ed1ab_0 conda-forge
tensorflow 2.3.0 mkl_py38h8c0d9a2_0
tensorflow-base 2.3.0 eigen_py38h75a453f_0
tensorflow-estimator 2.5.0 pyh81a9013_1 conda-forge
How to make it run in parallel on the VM with bigger data?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
