Tensorflow GPU启动时间长

Tensorflow GPU启动时间长,tensorflow,time,gpu,startup,rtx,Tensorflow,Time,Gpu,Startup,Rtx,我有这个问题,我知道很多人都听说过。我从使用GTX 1050 Ti的笔记本电脑升级到使用RTX 3060 Ti的PC。我在Anaconda虚拟环境中运行一切。我已经将我的env从笔记本电脑复制到PC上。现在TensorFlow GPU需要很多时间启动。即使我写了两行代码: from tensorflow.python.client import device_lib print(device_lib.list_local_devices()) 这需要很多时间(超过30分钟)。同样的东西在我的G

我有这个问题,我知道很多人都听说过。我从使用GTX 1050 Ti的笔记本电脑升级到使用RTX 3060 Ti的PC。我在Anaconda虚拟环境中运行一切。我已经将我的env从笔记本电脑复制到PC上。现在TensorFlow GPU需要很多时间启动。即使我写了两行代码:

from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
这需要很多时间(超过30分钟)。同样的东西在我的GTX 1050 Ti笔记本电脑上也能完美运行。 我试了很多东西:

  • 在另一个环境中重新安装每个软件包(当然,相同的版本-我使用的是TF 2.1、cudnn 7.6.5、cudatoolkit 10.1.243)
  • 在我的程序前放几行代码(我尝试了10多种不同的可能性)
  • 重新安装并清洁GPU驱动程序
TensorFlow启动后,RTX 3060 Ti工作正常,训练速度非常快。 我在谷歌上搜索了很多,但我发现现在仍然有很多人在我的位置上,所以我不希望很快得到答案:)

无论如何,如果有人找到了答案,请与我分享!提前感谢,祝你度过愉快的一天

另外,如果您需要代码或控制台日志,请点击这里。我已经编写了一个快速MNIST程序:

from tensorflow.keras.datasets import mnist
from tensorflow.keras.utils import to_categorical
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Conv2D
from tensorflow.keras.layers import MaxPooling2D
from tensorflow.keras.layers import Dense
from tensorflow.keras.layers import Flatten
from tensorflow.keras.optimizers import SGD
from numpy import mean
from numpy import std
from matplotlib import pyplot as plt
from sklearn.model_selection import KFold

# Load and prepare the train and test set
def load_dataset():
    # Load the dataset
    (trainX, trainY), (testX, testY) = mnist.load_data()
    # Reshape the dataset to have a single channel
    trainX = trainX.reshape((trainX.shape[0], 28, 28, 1))
    testX = testX.reshape((testX.shape[0], 28, 28, 1))
    # One hot encode target values
    trainY = to_categorical(trainY)
    testY = to_categorical(testY)
    return trainX, trainY, testX, testY

# Scale pixels
def prep_pixels(train, test):
    # Convert from integers to float
    train_norm = train.astype('float32')
    test_norm = test.astype('float32')
    # Normalize to range 0-1
    train_norm = train_norm / 255.0
    test_norm = test_norm / 255.0
    return train_norm, test_norm

# Define the CNN classifier
def define_classifier():
    # Build the structure
    classifier = Sequential()
    classifier.add(Conv2D(32, (3, 3), activation = 'relu', input_shape = (28, 28, 1)))
    classifier.add(MaxPooling2D(pool_size = (2, 2)))
    classifier.add(Conv2D(64, (3, 3), activation = 'relu'))
    classifier.add(Conv2D(64, (3, 3), activation = 'relu'))
    classifier.add(MaxPooling2D((2, 2)))
    classifier.add(Flatten())
    classifier.add(Dense(100, activation = 'relu'))
    classifier.add(Dense(10, activation = 'softmax'))
    # Compile the model
    classifier.compile(optimizer = SGD(lr = 0.01, momentum = 0.9), loss = 'categorical_crossentropy',
                       metrics = ['accuracy'])
    return classifier

# Evaluate the classifier using the K-Fold Cross-Validation
def evaluate_classifier(dataX, dataY, n_folds = 5):
    scores, histories = list(), list()
    # Prepare Cross-Validation
    kfold = KFold(n_folds, shuffle = True, random_state = 1)
    # Enumerate splits
    for trainX_i, testX_i in kfold.split(dataX):
        # Define classifier
        classifier = define_classifier()
        # Select rows for train and test
        trainX, trainY, testX, testY = dataX[trainX_i], dataY[trainX_i], dataX[testX_i], dataY[testX_i]
        # Fit the classifier
        history = classifier.fit(trainX, trainY, batch_size = 32, epochs = 10, 
                                 validation_data = (testX, testY), verbose = 1)
        # Evaluate the classifier
        _, acc = classifier.evaluate(testX, testY, verbose = 1)
        print('> ACC: %.3f' % (acc * 100.0))
        # Store history, accuracy
        scores.append(acc)
        histories.append(history)
    return scores, histories

# Plot learning curves
def visualise_learning(histories):
    for i in range(len(histories)):
        plt.tight_layout()
        # Plot LOSS
        plt.subplot(2, 1, 1)
        plt.title('Cross-Entropy Loss')
        plt.plot(histories[i].history['loss'], color = 'blue', label = 'train')
        plt.plot(histories[i].history['val_loss'], color = 'orange', label = 'test')
        # Plot ACCURACY
        plt.subplot(2, 1, 2)
        plt.title('Classification Accuracy')
        plt.plot(histories[i].history['accuracy'], color = 'blue', label = 'train')
        plt.plot(histories[i].history['val_accuracy'], color = 'orange', label = 'test')
    plt.show()

# Summarize classifier performance
def summarize_performance(scores):
    print('Accuracy: mean=%.3f std=%.3f, n=%d' % (mean(scores) * 100, std(scores) * 100, len(scores)))
    
# Run all parts together
def run():
    trainX, trainY, testX, testY = load_dataset()
    trainX, testX = prep_pixels(trainX, testX)
    scores, histories = evaluate_classifier(trainX, trainY)
    visualise_learning(histories)
    summarize_performance(scores)
  
def save_model():
    trainX, trainY, testX, testY = load_dataset()
    trainX, testX = prep_pixels(trainX, testX)
    classifier = define_classifier()
    classifier.fit(trainX, trainY, epochs = 25, batch_size = 32, verbose = 1)
    classifier.save('final_classifier.h5')
    
##############################################################################################################

# make a prediction for a new image.
from tensorflow.keras.preprocessing.image import load_img
from tensorflow.keras.preprocessing.image import img_to_array
from tensorflow.keras.models import load_model

# load and prepare the image
def load_image(filename):
    # load the image
    img = load_img(filename, grayscale=True, target_size=(28, 28))
    # convert to array
    img = img_to_array(img)
    # reshape into a single sample with 1 channel
    img = img.reshape(1, 28, 28, 1)
    # prepare pixel data
    img = img.astype('float32')
    img = img / 255.0
    return img

# load an image and predict the class
def run_example():
    # load the image
    img = load_image('image.png')
    # load model
    model = load_model('final_classifier.h5')
    # predict the class
    digit = model.predict_classes(img)
    print(digit[0])

# entry point, run the example
#run_example()
run()
下面是控制台日志:

Python 3.7.9 (default, Aug 31 2020, 17:10:11) [MSC v.1916 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.

IPython 7.19.0 -- An enhanced Interactive Python.

runcell(0, 'C:/Python/Projects/Handwritten Digit Recognition/digit_recognizer.py')

2021-01-14 13:47:28.396292: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll

2021-01-14 13:47:28.396292: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2021-01-14 13:47:31.018731: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
2021-01-14 13:47:31.041720: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties: 
pciBusID: 0000:01:00.0 name: GeForce RTX 3060 Ti computeCapability: 8.6
coreClock: 1.8GHz coreCount: 38 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 417.29GiB/s
2021-01-14 13:47:31.041751: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll

2021-01-14 13:47:28.396292: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2021-01-14 13:47:31.018731: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
2021-01-14 13:47:31.041720: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties: 
pciBusID: 0000:01:00.0 name: GeForce RTX 3060 Ti computeCapability: 8.6
coreClock: 1.8GHz coreCount: 38 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 417.29GiB/s
2021-01-14 13:47:31.041751: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2021-01-14 13:47:31.395981: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2021-01-14 13:47:31.430370: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2021-01-14 13:47:31.452057: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2021-01-14 13:47:31.659034: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2021-01-14 13:47:31.837570: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2021-01-14 13:47:32.055598: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2021-01-14 13:47:32.056116: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0

2021-01-14 13:47:28.396292: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2021-01-14 13:47:31.018731: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
2021-01-14 13:47:31.041720: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties: 
pciBusID: 0000:01:00.0 name: GeForce RTX 3060 Ti computeCapability: 8.6
coreClock: 1.8GHz coreCount: 38 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 417.29GiB/s
2021-01-14 13:47:31.041751: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2021-01-14 13:47:31.395981: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2021-01-14 13:47:31.430370: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2021-01-14 13:47:31.452057: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2021-01-14 13:47:31.659034: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2021-01-14 13:47:31.837570: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2021-01-14 13:47:32.055598: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2021-01-14 13:47:32.056116: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0
2021-01-14 13:47:32.652696: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
2021-01-14 13:47:32.655023: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties: 
pciBusID: 0000:01:00.0 name: GeForce RTX 3060 Ti computeCapability: 8.6
coreClock: 1.8GHz coreCount: 38 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 417.29GiB/s
2021-01-14 13:47:32.655039: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2021-01-14 13:47:32.655046: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2021-01-14 13:47:32.655051: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2021-01-14 13:47:32.655057: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2021-01-14 13:47:32.655062: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2021-01-14 13:47:32.655067: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2021-01-14 13:47:32.655072: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2021-01-14 13:47:32.655095: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0

2021-01-14 13:47:28.396292: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2021-01-14 13:47:31.018731: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
2021-01-14 13:47:31.041720: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties: 
pciBusID: 0000:01:00.0 name: GeForce RTX 3060 Ti computeCapability: 8.6
coreClock: 1.8GHz coreCount: 38 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 417.29GiB/s
2021-01-14 13:47:31.041751: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2021-01-14 13:47:31.395981: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2021-01-14 13:47:31.430370: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2021-01-14 13:47:31.452057: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2021-01-14 13:47:31.659034: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2021-01-14 13:47:31.837570: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2021-01-14 13:47:32.055598: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2021-01-14 13:47:32.056116: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0
2021-01-14 13:47:32.652696: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
2021-01-14 13:47:32.655023: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties: 
pciBusID: 0000:01:00.0 name: GeForce RTX 3060 Ti computeCapability: 8.6
coreClock: 1.8GHz coreCount: 38 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 417.29GiB/s
2021-01-14 13:47:32.655039: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2021-01-14 13:47:32.655046: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2021-01-14 13:47:32.655051: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2021-01-14 13:47:32.655057: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2021-01-14 13:47:32.655062: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2021-01-14 13:47:32.655067: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2021-01-14 13:47:32.655072: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2021-01-14 13:47:32.655095: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0
2021-01-14 13:50:57.038023: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1096] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-01-14 13:50:57.038040: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102]      0 
2021-01-14 13:50:57.038045: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] 0:   N 
2021-01-14 13:50:57.039526: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1241] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 6699 MB memory) -> physical GPU (device: 0, name: GeForce RTX 3060 Ti, pci bus id: 0000:01:00.0, compute capability: 8.6)
Train on 48000 samples, validate on 12000 samples
Epoch 1/10

2021-01-14 13:47:28.396292: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2021-01-14 13:47:31.018731: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
2021-01-14 13:47:31.041720: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties: 
pciBusID: 0000:01:00.0 name: GeForce RTX 3060 Ti computeCapability: 8.6
coreClock: 1.8GHz coreCount: 38 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 417.29GiB/s
2021-01-14 13:47:31.041751: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2021-01-14 13:47:31.395981: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2021-01-14 13:47:31.430370: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2021-01-14 13:47:31.452057: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2021-01-14 13:47:31.659034: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2021-01-14 13:47:31.837570: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2021-01-14 13:47:32.055598: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2021-01-14 13:47:32.056116: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0
2021-01-14 13:47:32.652696: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
2021-01-14 13:47:32.655023: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties: 
pciBusID: 0000:01:00.0 name: GeForce RTX 3060 Ti computeCapability: 8.6
coreClock: 1.8GHz coreCount: 38 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 417.29GiB/s
2021-01-14 13:47:32.655039: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2021-01-14 13:47:32.655046: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2021-01-14 13:47:32.655051: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2021-01-14 13:47:32.655057: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2021-01-14 13:47:32.655062: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2021-01-14 13:47:32.655067: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2021-01-14 13:47:32.655072: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2021-01-14 13:47:32.655095: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0
2021-01-14 13:50:57.038023: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1096] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-01-14 13:50:57.038040: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102]      0 
2021-01-14 13:50:57.038045: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] 0:   N 
2021-01-14 13:50:57.039526: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1241] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 6699 MB memory) -> physical GPU (device: 0, name: GeForce RTX 3060 Ti, pci bus id: 0000:01:00.0, compute capability: 8.6)
2021-01-14 13:50:57.563527: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll

2021-01-14 13:47:28.396292: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2021-01-14 13:47:31.018731: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
2021-01-14 13:47:31.041720: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties: 
pciBusID: 0000:01:00.0 name: GeForce RTX 3060 Ti computeCapability: 8.6
coreClock: 1.8GHz coreCount: 38 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 417.29GiB/s
2021-01-14 13:47:31.041751: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2021-01-14 13:47:31.395981: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2021-01-14 13:47:31.430370: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2021-01-14 13:47:31.452057: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2021-01-14 13:47:31.659034: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2021-01-14 13:47:31.837570: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2021-01-14 13:47:32.055598: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2021-01-14 13:47:32.056116: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0
2021-01-14 13:47:32.652696: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
2021-01-14 13:47:32.655023: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties: 
pciBusID: 0000:01:00.0 name: GeForce RTX 3060 Ti computeCapability: 8.6
coreClock: 1.8GHz coreCount: 38 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 417.29GiB/s
2021-01-14 13:47:32.655039: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2021-01-14 13:47:32.655046: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2021-01-14 13:47:32.655051: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2021-01-14 13:47:32.655057: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2021-01-14 13:47:32.655062: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2021-01-14 13:47:32.655067: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2021-01-14 13:47:32.655072: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2021-01-14 13:47:32.655095: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0
2021-01-14 13:50:57.038023: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1096] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-01-14 13:50:57.038040: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102]      0 
2021-01-14 13:50:57.038045: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] 0:   N 
2021-01-14 13:50:57.039526: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1241] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 6699 MB memory) -> physical GPU (device: 0, name: GeForce RTX 3060 Ti, pci bus id: 0000:01:00.0, compute capability: 8.6)
2021-01-14 13:50:57.563527: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2021-01-14 13:52:17.763274: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
 7232/48000 [===>..........................] - ETA: 1:21:26 - loss: 2.3010 - accuracy: 0.1114  
2021-01-14 13:47:28.396292: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2021-01-14 13:47:31.018731: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
2021-01-14 13:47:31.041720: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties: 
pciBusID: 0000:01:00.0 name: GeForce RTX 3060 Ti computeCapability: 8.6
coreClock: 1.8GHz coreCount: 38 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 417.29GiB/s
2021-01-14 13:47:31.041751: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2021-01-14 13:47:31.395981: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2021-01-14 13:47:31.430370: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2021-01-14 13:47:31.452057: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2021-01-14 13:47:31.659034: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2021-01-14 13:47:31.837570: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2021-01-14 13:47:32.055598: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2021-01-14 13:47:32.056116: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0
2021-01-14 13:47:32.652696: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
2021-01-14 13:47:32.655023: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties: 
pciBusID: 0000:01:00.0 name: GeForce RTX 3060 Ti computeCapability: 8.6
coreClock: 1.8GHz coreCount: 38 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 417.29GiB/s
2021-01-14 13:47:32.655039: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2021-01-14 13:47:32.655046: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2021-01-14 13:47:32.655051: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2021-01-14 13:47:32.655057: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2021-01-14 13:47:32.655062: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2021-01-14 13:47:32.655067: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2021-01-14 13:47:32.655072: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2021-01-14 13:47:32.655095: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0
2021-01-14 13:50:57.038023: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1096] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-01-14 13:50:57.038040: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102]      0 
2021-01-14 13:50:57.038045: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] 0:   N 
2021-01-14 13:50:57.039526: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1241] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 6699 MB memory) -> physical GPU (device: 0, name: GeForce RTX 3060 Ti, pci bus id: 0000:01:00.0, compute capability: 8.6)
2021-01-14 13:50:57.563527: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2021-01-14 13:52:17.763274: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2021-01-14 14:05:23.645822: W tensorflow/stream_executor/gpu/redzone_allocator.cc:312] Internal: Invoking GPU asm compilation is supported on Cuda non-Windows platforms only
Relying on driver to perform ptx compilation. This message will be only logged once.
48000/48000 [==============================] - 869s 18ms/sample - loss: 2.3019 - accuracy: 0.1101 - val_loss: 2.3014 - val_accuracy: 0.1144

在“添加可见gpu设备:0”一行以及之后打开动态库之后,花费了很多时间。

GTX 1050 Ti
卡基于
Pascal
体系结构,兼容的
CUDA版本从8.x开始,其中as
RTX 3060 Ti
卡基于
Ampere
架构,兼容的
CUDA版本从11.x开始

因此,gpu卡的兼容tensorflow版本是
2.4.0
,而cuDNN是
8.0


感谢njuffa的支持和见解。您可以检查tensorflow测试的和的构建配置。

一个有根据的猜测:由于CUDA 10.x和相关库不包含安培二进制文件,许多代码是从包含的PTX中间格式JIT编译成安培机器代码。@njuffa那么我需要更改CUDA版本(因此cudnn)?如果是,哪个版本支持安培GPU?非常感谢你的回答!请注意,Tensorflow和CUDNN版本之间可能存在严格的依赖关系。我不使用Tensorflow,也对它们一无所知,但你应该先研究一下。CUDNN支持列表可在此处找到:感谢您的链接!似乎只有11.0以上的版本才支持安培GPU。我将研究哪个tensorflow版本与它兼容,明天我将给出答复(目前在我的国家是晚上11点)。我真的很感谢你的帮助!请注意,这是一个问答网站,不是一个有讨论线索的论坛。我个人认为这个问题偏离主题,因为它不是一个编程问题,而是一个软件配置问题。