What I got into when using Tensorflow-gpu

I was addicted to machine learning using tensorflow, so I will describe it.

environment

environment version
OS Windows
tensorflow 2.3.0
CUDA 11.0

problem

import tensorflow as tf
mnist = tf.keras.datasets.mnist

(x_train, y_train),(x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0

model = tf.keras.models.Sequential([
  tf.keras.layers.Flatten(input_shape=(28, 28)),
  tf.keras.layers.Dense(512, activation=tf.nn.relu),
  tf.keras.layers.Dropout(0.2),
  tf.keras.layers.Dense(10, activation=tf.nn.softmax)
])
model.compile(optimizer='adam',
              loss='sparse_categorical_crossentropy',
              metrics=['accuracy'])

model.fit(x_train, y_train, epochs=5)
model.evaluate(x_test, y_test)

When trying to execute code like the one above

F .\tensorflow/core/kernels/random_op_gpu.h:232] Non-OK-status: GpuLaunchKernel(FillPhiloxRandomKernelLaunch<Distribution>, num_blocks, block_size, 0, d.stream(), gen, data, size, dist) status: Internal: invalid configuration argument

Error occurred and it became impossible to execute.

This error

import os
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"

It was possible to avoid it by setting it not to use GPU. I thought it was caused by CUDA and tried downloading it again and reviewing the path settings, but the result did not change ...

solution

pip install tf-nightly-gpu

I was able to solve it. Apparently I thought it was tf-nightly-gpu, but it seemed to be the latest version of tensorflow and newer than 2.3.0.

pip list

When I look it up in

tf-estimator-nightly     2.4.0.dev2020091501
tf-nightly-gpu           2.4.0.dev20200912

It seemed to be in the development stage.

I didn't know why this solved the error ...

reference

https://itips.krsw.biz/tensorflow-keras-gpu-deactivate/ https://github.com/tensorflow/tensorflow/issues/30665

Recommended Posts

What I got into when using Tensorflow-gpu
5 reasons I got into Python
I got an error when using Tensorboard with Pytorch
What I was addicted to when using Python tornado
I got a Value Error when using JUMAN ++ with PyKNP
What I was asked when using Random Forest in practice
What I stumbled upon using Airflow
I got a TypeError:'int' object is not iterable when using keras
Scribble what I used when using ipython in formatting pos data
What I stumbled upon when using CodeIgniter on a Linux server
What I referred to when studying tkinter
What Rubyist should know when using pyenv
What I got from Python Boot Camp
A reminder of what I got stuck when starting Atcoder with python
[Ansible] What I am careful about when writing ansible
What I did when I got stuck in the time limit with lambda python
What I did when updating from Python 2.6 to 2.7
[Question] What happens when I use% in python?
Linux Ubuntu16.04 I got a little scary error when I ran a command using sudo
What are you using when testing with Python?
What I learned about AI / machine learning using Python (1)
When I tried to introduce python3 to atom, I got stuck
What I did when I stumbled on a Django tutorial
I got a UnicodeDecodeError when pip install on ubuntu
What I learned about AI / machine learning using Python (3)
What I learned about AI / machine learning using Python (2)
I tried using parameterized
I tried using argparse
I tried using mimesis
A note of what I learned when I thought about using pyenv or virtualenv on Windows
I tried using anytree
I tried using aiomysql
I tried using Summpy
I got "ModuleNotFoundError: No module named'azure'" when running a program using Azure SDK for Python
I tried using coturn
I tried using Pipenv
I tried using matplotlib
I tried using "Anvil".
I tried using Hubot
I tried using ESPCN
I tried using openpyxl
I tried using Ipython
I tried using PyCaret
I tried using cron
I tried using ngrok
I tried using face_recognition
I tried using Jupyter
I got a sqlite3.OperationalError
I tried using PyCaret
I tried using Heapq
I tried using doctest
Precautions when using Chainer
I tried using folium
I tried using jinja2
I tried using folium
I tried using time-window
What I was addicted to when I built my own neural network using the weights and biases I got with scikit-learn's MLP Classifier.
What I was careful about when implementing Airflow with docker-compose
When I made CaboCha usable with python3, I got stuck (Windows 10)
What I got stuck around GUI in WSL python environment
What I learned about AI and machine learning using Python (4)