Cannot write buffer for DAG

Update 2021 – While the points in the article are still valid and the solution will continue to work if you do encounter this problem, I just wanted to point out that the Ethereum (ETH) DAG has grown beyond the 4 GB limit. Any mention of using 4 GB cards will no longer work when mining Ethereum, but I left the post as originally written. So this fix will still work with 6 GB+ graphic cards.

With the recent uptick in Ethereum (ETH) prices, I was dusting off some of my old mining gear and ended up consolidating some of my more efficient GPUs into a few rebuilt mining rigs. On one of the rigs, I came across the “OpenCL error -4 – Cannot write buffer for DAG” error., and thought I would do a quick post covering what it means and what can be done to avoid it.

Most of the time the cause of this “Cannot write buffer for DAG” error is due to not having enough virtual memory assigned on the computer (or rig) you are attempting to mine with. When using the Claymore ETH miner at least, and I would imagine with others as well, a good rule of thumb is to reserve as much virtual memory as you have total GPU RAM.

For instance, if you are using a rig with 6 GPUs, and each GPU has 4 GB of RAM, you would need to allocate 6 x 4 GB, or 24 GB in total of virtual memory. The same guideline would apply for a rig with six 8 GB GPUs as well. Except in this case, it would require 6 x 8 GB, or 48 GB in total of virtual memory.

If you are using 8 GB cards, you can get by with less virtual memory as you only need enough reserved to cover the DAG generation. So for now you would be fine with 24 GB of virtual memory as with the 4GB example above.

However, I would still try and allocate as much virtual memory as possible if you have the resources. Considering most dedicated mining rigs only perform mining and nothing else, you really do not need much extra hard disk space than what you need for the OS, drivers, mining software and maybe a few GBs extra for overhead.

So an affordable 120 GB SSD, will provide plenty of capacity for virtual memory. With this size SSD, you can fit the OS, drivers, mining software and a few other programs comfortably within 50 GB. Even when accounting for a 10 GB cushion for overhead, you would still have close to 60 GB left over to use as virtual memory.

You can adjust your computer’s virtual memory settings in Windows 10 by first going to Control Panel->System and Security->System. You can simultaneously press the Win + break shortcut keys to get here quickly.

You can alternatively right click on “This PC” in Windows explorer and click on properties to arrive at the same window.

System Properties
System Properties

Once inside the System Properties window, click on the Advanced tab. Then under the Performance section, click on Settings, as shown in the image above.

Performance Options
Performance Options

Now in the Performance options window, click on the Advanced tab. Then in the Virtual memory section click on the change button.

Virtual Memory
Virtual Memory

This will bring up the Virtual Memory window as shown above.

By default, the “Automatically manage paging file size of all drives” is checked and all the other options will be greyed out. Uncheck this box (#1) to enable the editing of the options we need to make changes to.

Now a bit lower down (#2) click on the Custom size radio button to allow us to specify the amount of virtual memory we wish to set aside. In my example I am using 24 GB (24,000 MB) of RAM as both the Initial and Maximum size values. This is basically dedicating a set amount of 24 GB for virtual memory.

Adjust your settings based on the guidelines above for matching the amount of GPU RAM, or just use the maximum amount you can while still leaving some headroom for the OS and other files, plus about 10 GB.

After entering in your desired values, you will need to press the Set button (#3) and then OK (#4) out of the dialog.

Continue to OK out of any remaining open dialog windows and you will then need to reboot you computer for the changes to take effect.


Once your computer has rebooted, you can easily verify your new page file (virtual memory) settings have taken effect. Do this by opening Windows explorer and looking at your C drive.

You should see a pagefile.sys file with the size set to the amount of memory you chose in the earlier procedure.

Folder Options
Folder Options

Note, if you do not see the pagefile system file at all, you may need to click on View at the top of the Windows explorer menu and check the “Hidden items” checkbox as well as going into View->Options->View and unchecking the Hide operating systems files checkbox.

Now when you retry mining using Claymore (or other) Ethereum miner, you should no longer encounter the “Cannot write buffer for DAG” error.

1 Comment

  1. I have a friend who has also seen this on one of their Nvidia machines, they got a similar error that reads “CUDA error – cannot allocate big buffer for DAG”. The virtual memory solution worked for them as well.

    You basically need your VM equal to the current DAG size times the number of GPUs you have. Keep in mind the DAG size is continually growing, so plan ahead.

    As mentioned in the article, a good rule of thumb is to take your GPU ram multiplied by the number of GPUs you have to size your computer’s virtual memory.

Leave a Reply

Your email address will not be published.