TensorFlow GPU配置

0 引言

刚开始配置好了之后,手贱卸载了,然后重新配置出现了问题。卸载了之前的cudn8,重新安装不成功,在此记录。

1 详细

(1)第一步,卸载所有cudn以前的版本。重新下载cudn安装,如果安装失败,请往下看,否则就不用看了。

(2)第二步,干脆点,把驱动也给卸载了。使用一款超级好用的软件,DDU(Display Driver Uninstaller),链接:https://www.wagnardsoft.com/forums/viewtopic.php?f=5&t=1069

具体的,看https://www.wagnardsoft.com/content/ddu-guide-tutorial所述。以下是截自该网址内容。可使用翻译辅助看。

==

Step 1 - Have your GPU drivers ready (but do not run them yet)
Before we go ahead and use DDU to remove our GPU drivers I highly recommend beforehand you head to your GPU manufacturers website and download the appropriate drivers for your GPU and OS configuration (I recommend you use the latest drivers available, however you can use older drivers if you want)

 

Here are the official download links for NVIDIA, AMD (ATI) and Intel drivers. Make sure you select the right options such as language, OS version and architecture etc.

 

NVIDIA: www.nvidia.com/Download/index.aspx

AMD (ATI): support.amd.com/en-us/download

Intel: https://downloadcenter.intel.com/

 

- Note: With some computers you may have to download your GPU drivers from the OEMs website (HP, Dell, Lenovo etc.) - some GPUs may have custom hardware IDs that only officially work with the OEM specific drivers; however this isn't common.

 

Step 2 - Download DDU

After you've downloaded your GPU drivers we can now go ahead and download DDU, I recommend you download DDU from Wagnard's official site.

 

DDU Download: https://www.wagnardsoft.com/display-driver-uninstaller-ddu-

 

I always recommend you download the latest version of DDU, it gets updated quite regularly to keep up with the changes made to GPU drivers and Windows.

Step 2.5 - Disconnect from the Internet (Windows 10 only)

If you're using Windows 10, I recommend (if not mandatory) you disconnect your PC from the Internet, this will prevent Windows 10 from automatically downloading GPU drivers.

There is an alternative option in the option menu of DDU that you can select that should prevent the download of drivers from window update.

Step 3 - Extract and run DDU

Once you've download DDU, simply double click the exe and extract it wherever you want (except on a network drive, it must be on a local disk), I recommend you extract DDU to a 'DDU' folder on the desktop, for ease of access.

Once you've extracted DDU, open the DDU folder (or wherever you extracted it) and you should see several files, read the 'Readme' file, then launch 'Display Driver Uninstaller'.

After you run 'Display Driver Uninstaller' you'll be presented with a warning box, advising you to launch DDU in Safe Mode, I highly recommend you use DDU in Safe Mode to minimize any potential issues, however it's optional. If you do not want to launch DDU in Safe Mode, just click 'OK' and proceed as normal.

If you do want to launch DDU in Safe Mode click the OK button, in the top left-hand corner select 'Options' and at the bottom click 'Enable Safe Mode dialog', exit out of DDU and relaunch it, upon relaunching select "Safe Mode (Recommended)" and click "Reboot to Safe Mode". Your PC should reboot into Safe Mode and DDU will start.

*Note1: It is preferable to use the "Enable Safe Mode dialog" option only after you have at least tried once to go into safe mode the usual way or YOU MAY GET STUCK in safe mode.

*Note2: If you use DDU in normal mode I recommend you close down any background programs, such as games, browsers, media players etc…

 

After launching DDU you will be presented with this screen, instead of simply clicking one of the removal buttons I recommend you head to the options and tweak how DDU removes the drivers.

 

I recommend you select the C:\NVIDIA and C:\AMD folders
 

 

These folders are the default locations where the NVIDIA or AMD driver installation files are unpacked, once the driver is installed these folders can safely be deleted.

 

Once this has been done exit the options menu and now we can begin using DDU to remove our GPU drivers.

 

On the right side you'll see a drop down box that allows you to select what GPU drivers you want to remove.

 

If you previously had an AMD (ATI) GPU in your system and then made the switch to NVIDIA (or vice versa) in the same Windows installation, you will want to remove the AMD drivers and then the NVIDIA drivers (or vice versa) to avoid any conflicts

 

Intel iGPU (HD, Iris graphics) drivers shouldn't cause any conflicts between AMD or NVIDIA drivers. However, having assets of AMD drivers installed on an NVIDIA system, or vice versa can cause issues.

 

 

On the left side of the interface you'll see three buttons, all are relatively quite simple but I'll run through them quickly.

 

  • Clean and restart
    Will remove the current selected GPU drivers and reboot. This is great if you've only had a single GPU installed and you want to clean your drivers. It will reboot and you can start clean with the drivers you downloaded earlier

 

  • Clean and do NOT restart
    This is the option you'd want to select if you've had multiple GPUs installed in the past, remove the AMD (ATI) drivers, change it to NVIDIA and remove those drivers (or vice versa)

    This allows you to completely remove any GPU drivers from your system and start completely fresh.

 

  • Clean and shutdown
    Will remove the currently selected GPU drivers and shutdown your system. This should be used if you intend to swap out your GPU

 

  • Remove “GeForce Experience” display driver installer cache/files (NVIDIA only)
    This will remove cache/temporary files that are created when installing NVIDIA drivers or the GeForce experience, this is intended for use after you've installed your NVIDIA drivers, it typically will remove 600MB or more
     

 

Now all we have left to do is remove our drivers, personally I use the ‘Clean and DO NOT restart' option the most and recommend others do the same, it allows you to see what's being removed and you can select between AMD (ATI), NVIDIA and Intel to make sure no conflicts are occurring if you've had different GPUs in your system. Your screen may go black for a few seconds while DDU is removing the GPU drivers - this is perfectly normal and should only last a few seconds.

Select your GPU vendor

Select one of the removal options, I recommend you click ‘Clean and do NOT restart' if you wish to look at the logs or by default, click 'Clean and restart'.

DDU will now remove the selected GPU drivers from your system, this will vary depending on the speed of your system.

 

I just want to reiterate one more time, if you've had an AMD (ATI) or NVIDIA GPU in the same install of Windows I highly recommend you select and remove both GPU drivers to make sure there aren't any conflicts. Once DDU has completed the removal of the selected GPU drivers you will be prompted with this message -- Select ‘Yes' to exit the program.

Now DDU will reboot your PC, from here you can install the GPU drivers you downloaded earlier, restart if applicable and then connect your PC back to the internet.

 

(NVIDIA only) After you've installed your GPU drivers, you can go ahead and open up DDU (you don't need to do this in Safe Mode) and remove temporary/cache NVIDIA driver/GFE installation files, for me it was around 1GB

 

As a side note I always recommend you update your GPU drivers using the official installer, programs like GeForce Experience can cause issues when updating drivers.

 

If you found DDU useful, please consider donating to Wagnard so he can continue improving DDU by adding new features and updating it when changes are made to Windows or the drivers themselves. Patreon Link | PayPal Link

 

Hopefully this guide has helped you resolve any GPU driver related issues you may have encountered, although I realise this guide won't help everyone. GPU drivers are incredibly complex pieces of software and this is merely one fix. Below I have other tutorials that may help you resolve any issues that are related to GPU drivers.

==

重启后再重新安装cuda 即可成功。

然后下载相对应的cudnn,将解压出来的文件直接复制在cuda目录下,就行了。

使用下面的程序验证是否安装gpu成功,

import tensorflow as tf
# Creates a graph.
# with tf.device('/gpu:0'):
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)
# Creates a session with log_device_placement set to True.
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
# Runs the op.
print(sess.run(c))

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值