canonical / canonical/kubeflow-single-node-dgx

Few issues with running gpu-notebook on a jupyter-tensorflow-cuda-full:v1.10.0-rc.1 based jupyter notebook

Open
#2 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

While running this test on a newly deployed kubeflow environment, I encountered few issues.
I am listing down the issues and changes used to workaround the issues.
Note: However it is possible that these workarounds are not the best options to overcome the issues.

  1. There is a error at this cell.
# One hot encoding labels
y_train_encoded = keras.utils.to_categorical(y_train, num_classes = 10, dtype = 'float32')
y_test_encoded = keras.utils.to_categorical(y_test, num_classes = 10, dtype = 'float32')

This is the error.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[6], line 2
      1 # One hot encoding labels
----> 2 y_train_encoded = keras.utils.to_categorical(y_train, num_classes = 10, dtype = 'float32')
      3 y_test_encoded = keras.utils.to_categorical(y_test, num_classes = 10, dtype = 'float32')

TypeError: to_categorical() got an unexpected keyword argument 'dtype'

To overcome this we can simply drop the dtype attribute.

# One hot encoding labels
y_train_encoded = keras.utils.to_categorical(y_train, num_classes = 10)
y_test_encoded = keras.utils.to_categorical(y_test, num_classes = 10)
  1. There is a error at this cell.
# MultiGPU prediction. Run nvidia-smi command in another terminal tab to check GPU ussage
model_gpu = get_model_cnn()
model_gpu.fit(X_train_scaled, y_train_encoded, epochs=10, batch_size=64)

This is the error.

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[10], line 2
      1 # MultiGPU prediction. Run nvidia-smi command in another terminal tab to check GPU ussage
----> 2 model_gpu = get_model_cnn()
      3 model_gpu.fit(X_train_scaled, y_train_encoded, epochs=10, batch_size=64)

Cell In[9], line 17, in get_model_cnn()
     15 model.add(Dense(10, activation='softmax'))
     16 # compile model
---> 17 opt = keras.optimizers.SGD(lr=0.001, momentum=0.9)
     18 model.compile(optimizer=opt, loss='categorical_crossentropy', metrics=['accuracy'])
     19 return model

File /opt/conda/lib/python3.11/site-packages/keras/src/optimizers/sgd.py:60, in SGD.__init__(self, learning_rate, momentum, nesterov, weight_decay, clipnorm, clipvalue, global_clipnorm, use_ema, ema_momentum, ema_overwrite_frequency, loss_scale_factor, gradient_accumulation_steps, name, **kwargs)
     43 def __init__(
     44     self,
     45     learning_rate=0.01,
   (...)
     58     **kwargs,
     59 ):
---> 60     super().__init__(
     61         learning_rate=learning_rate,
     62         name=name,
     63         weight_decay=weight_decay,
     64         clipnorm=clipnorm,
     65         clipvalue=clipvalue,
     66         global_clipnorm=global_clipnorm,
     67         use_ema=use_ema,
     68         ema_momentum=ema_momentum,
     69         ema_overwrite_frequency=ema_overwrite_frequency,
     70         loss_scale_factor=loss_scale_factor,
     71         gradient_accumulation_steps=gradient_accumulation_steps,
     72         **kwargs,
     73     )
     74     if not isinstance(momentum, float) or momentum < 0 or momentum > 1:
     75         raise ValueError("`momentum` must be a float between [0, 1].")

File /opt/conda/lib/python3.11/site-packages/keras/src/backend/tensorflow/optimizer.py:21, in TFOptimizer.__init__(self, *args, **kwargs)
     20 def __init__(self, *args, **kwargs):
---> 21     super().__init__(*args, **kwargs)
     22     self._distribution_strategy = tf.distribute.get_strategy()

File /opt/conda/lib/python3.11/site-packages/keras/src/optimizers/base_optimizer.py:90, in BaseOptimizer.__init__(self, learning_rate, weight_decay, clipnorm, clipvalue, global_clipnorm, use_ema, ema_momentum, ema_overwrite_frequency, loss_scale_factor, gradient_accumulation_steps, name, **kwargs)
     86     warnings.warn(
     87         "Argument `decay` is no longer supported and will be ignored."
     88     )
     89 if kwargs:
---> 90     raise ValueError(f"Argument(s) not recognized: {kwargs}")
     92 if name is None:
     93     name = auto_name(self.__class__.__name__)

ValueError: Argument(s) not recognized: {'lr': 0.001}

To overcome this we need to replace lr with learning_rate in the get_model_cnn() function.

opt = keras.optimizers.SGD(learning_rate=0.001, momentum=0.9)
  1. There is a error at this cell.
# CPU only prediction
%%timeit -n1 -r1
# CPU
with tf.device('/CPU:0'):
    model_cpu = get_model()
    model_cpu.fit(X_train_scaled, y_train_encoded, epochs = 1)

This is the error.

UsageError: Line magic function `%%timeit` not found.

Need to move magic function above the comment line.

%%timeit -n1 -r1
# CPU only prediction

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the gpu-notebook cells described in the issue and run them in the jupyter-tensorflow-cuda-full:v1.10.0-rc.1 environment. Check the to_categorical, SGD, and %%timeit cells against the reported errors and apply the documented compatibility changes. Done means the notebook runs through these cells without the three reported errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, python, tensorflow
Domain
documentation, machine-learning
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.