问:
How to use a future without waiting for it?
The following example is taken from a C++ async tutorial:

```<code>#include <future>
#include <iostream>
#include <vector>

int twice(int m) { return 2 * m; }

int main() {
  std::vector<std::future<int>> futures;
  for(int i = 0; i < 10; ++i) { futures.push_back (std::async(twice, i)); }

  //retrive and print the value stored in the future
  for(auto &e : futures) { std::cout << e.get() << std::endl; }
  return 0;
}
</code>```

How can I use the result of a future without waiting for it? Ie I would like to do something like this:

```<code>  int sum = 0;
  for(auto &e : futures) { sum += someLengthyCalculation(e.get()); }
</code>```

I could pass a reference to the future to someLengthyCalculation, but at some point I have to call get to retrieve the value, thus I dont know how to write it without waiting for the first element being completed, before the next one can start summing.

答:
You are right that the current future library is not complete yet.  What we miss is a way to indicate 'when future x is ready, start operation f'.  Here's a nice post about that.

What you may want is a map/reduce implementation: upon each future's completion, you want to start adding it to the accumulator (reduce).

You can use a library for that - it's not very simple to build it yourself :).  One of the libraries that's gaining traction is RxCpp - and they have a post on map/reduce.

Body:
The following example is taken from a C++ async tutorial:

#include <future>
#include <iostream>
#include <vector>

int twice(int m) { return 2 * m; }

int main() {
  std::vector<std::future<int>> futures;
  for(int i = 0; i < 10; ++i) { futures.push_back (std::async(twice, i)); }

  //retrive and print the value stored in the future
  for(auto &e : futures) { std::cout << e.get() << std::endl; }
  return 0;
}

How can I use the result of a future without waiting for it? Ie I would like to do something like this:

  int sum = 0;
  for(auto &e : futures) { sum += someLengthyCalculation(e.get()); }

I could pass a reference to the future to someLengthyCalculation, but at some point I have to call get to retrieve the value, thus I dont know how to write it without waiting for the first element being completed, before the next one can start summing.


来源: stackexchange

问:
Mute video-bg not working
I've tried many guides and read many answers regarding this problem, still not managed to solve this. How do I mute my youtube embedded video?
P.s. I'm a noob at coding and new to SOF, forgive me if I did something horribly wrong.  </p>

```<code><div class="video-bg embed-responsive embed-responsive-16by9">

<iframe class="embed-responsive-item" width="560" height="315"
src="https://www.youtube.com/embed/ArGfDo1xQuM?rel=0&controls=0&showinfo=0&frameborder=0&autoplay=1&loop=1&playlist=eXadofBB7hM" frameborder="0" allowfullscreen></iframe>

</div>
</code>```

答:
You have to use iframe_api. In iframe src attribute you have to add enablejsapi=1, also iframe has id attribute that connects it with YT.Player instance. Then use this javascript to control movie playback.

```<code><script src='http://www.youtube.com/iframe_api'></script>
<script>
    var player;
    function onYouTubeIframeAPIReady() {
        player = new YT.Player('playerId', {
            events: {
                onReady:onPlayerReady
                }
            }
        )
    }
    function onPlayerReady(event) {
        player.mute();
        player.setVolume(0);
        player.playVideo();
    }
</script>

<div class="video-bg embed-responsive embed-responsive-16by9">

<iframe id='playerId' class="embed-responsive-item" width="560" height="315"
src="https://www.youtube.com/embed/ArGfDo1xQuM?rel=0&controls=0&showinfo=0&frameborder=0&autoplay=1&loop=1&playlist=eXadofBB7hM&enablejsapi=1" frameborder="0" allowfullscreen></iframe>

</div>
</code>```

ContentLicense: CC BY-SA 3.0

Title: Mute video-bg not working

Body:
You have to use iframe_api. In iframe src attribute you have to add enablejsapi=1, also iframe has id attribute that connects it with YT.Player instance. Then use this javascript to control movie playback.

<script src='http://www.youtube.com/iframe_api'></script>
<script>
    var player;
    function onYouTubeIframeAPIReady() {
        player = new YT.Player('playerId', {
            events: {
                onReady:onPlayerReady
                }
            }
        )
    }
    function onPlayerReady(event) {
        player.mute();
        player.setVolume(0);
        player.playVideo();
    }
</script>

<div class="video-bg embed-responsive embed-responsive-16by9">

<iframe id='playerId' class="embed-responsive-item" width="560" height="315"
src="https://www.youtube.com/embed/ArGfDo1xQuM?rel=0&controls=0&showinfo=0&frameborder=0&autoplay=1&loop=1&playlist=eXadofBB7hM&enablejsapi=1" frameborder="0" allowfullscreen></iframe>

</div>


问:
Fast Loading/Reading TIFF Files in C#
I'm writing a C# application that handles TIFF images (mainly displaying files, reordering pages, deleting pages, splitting multipage images, merging single images into one multipage image etc).

Most of the images we deal with are smaller (both in file size and in page numbers), but there are the odd larger ones.

When displaying the image, we need to split any multipage TIFF files into a List so the thumbnails can be displayed in a ListView. The issue we face is that for larger files, it takes way too long to perform the split. E.g. I just tested a 304 page image (which is only 10mb) and to split all the pages into the list took 137,145ms (137.14 seconds, or 2m 17s) which is far too slow.

The code I'm using is:

```<code>private void GetAllPages(string file)
{
    System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
    watch.Start();
    List<Image> images = new List<Image>();
    Bitmap bitmap = (Bitmap)Image.FromFile(file);
    int count = bitmap.GetFrameCount(FrameDimension.Page);
    for (int idx = 0; idx < count; idx++)
    {
        // save each frame to a bytestream
        bitmap.SelectActiveFrame(FrameDimension.Page, idx);
        System.IO.MemoryStream byteStream = new System.IO.MemoryStream();
        bitmap.Save(byteStream, ImageFormat.Tiff);

        // and then create a new Image from it
        images.Add(Image.FromStream(byteStream));
    }
    watch.Stop();
    MessageBox.Show(images.Count.ToString() + "\nTime taken: " + watch.ElapsedMilliseconds.ToString());
}
</code>```

Any hints or pointers on what I can do or what I should look at to speed up this process? I KNOW it can be done significantly faster - I just don't know how.

Thanks!

答:
If I use the TiffBitmapDecoder class from PresentationCore.dll (WPF) and then use it to create Bitmap instances, I get much faster loading of the frames (10s vs. 70s for a 150 MB TIFF with 360 frames).

```<code> List<Image> images = new List<Image>();
 Stream imageStreamSource = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read);
 TiffBitmapDecoder decoder = new TiffBitmapDecoder(imageStreamSource, BitmapCreateOptions.None, BitmapCacheOption.Default);
 foreach (BitmapSource bitmapSource in decoder.Frames)
 {
     Bitmap bmp = new Bitmap(bitmapSource.PixelWidth, bitmapSource.PixelHeight, PixelFormat.Format32bppPArgb);
     BitmapData data = bmp.LockBits(new Rectangle(System.Drawing.Point.Empty, bmp.Size), ImageLockMode.WriteOnly, PixelFormat.Format32bppPArgb);
     bitmapSource.CopyPixels(Int32Rect.Empty,  data.Scan0,  data.Height * data.Stride, data.Stride);
     bmp.UnlockBits(data);
     images.Add(bmp);
 }
</code>```

Title: Fast Loading/Reading TIFF Files in C#

Body:
I'm writing a C# application that handles TIFF images (mainly displaying files, reordering pages, deleting pages, splitting multipage images, merging single images into one multipage image etc).

Most of the images we deal with are smaller (both in file size and in page numbers), but there are the odd larger ones.

When displaying the image, we need to split any multipage TIFF files into a List so the thumbnails can be displayed in a ListView. The issue we face is that for larger files, it takes way too long to perform the split. E.g. I just tested a 304 page image (which is only 10mb) and to split all the pages into the list took 137,145ms (137.14 seconds, or 2m 17s) which is far too slow.

The code I'm using is:

private void GetAllPages(string file)
{
    System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
    watch.Start();
    List<Image> images = new List<Image>();
    Bitmap bitmap = (Bitmap)Image.FromFile(file);
    int count = bitmap.GetFrameCount(FrameDimension.Page);
    for (int idx = 0; idx < count; idx++)
    {
        // save each frame to a bytestream
        bitmap.SelectActiveFrame(FrameDimension.Page, idx);
        System.IO.MemoryStream byteStream = new System.IO.MemoryStream();
        bitmap.Save(byteStream, ImageFormat.Tiff);

        // and then create a new Image from it
        images.Add(Image.FromStream(byteStream));
    }
    watch.Stop();
    MessageBox.Show(images.Count.ToString() + "\nTime taken: " + watch.ElapsedMilliseconds.ToString());
}

Any hints or pointers on what I can do or what I should look at to speed up this process? I KNOW it can be done significantly faster - I just don't know how.

Thanks!

Body:
If I use the TiffBitmapDecoder class from PresentationCore.dll (WPF) and then use it to create Bitmap instances, I get much faster loading of the frames (10s vs. 70s for a 150 MB TIFF with 360 frames).

 List<Image> images = new List<Image>();
 Stream imageStreamSource = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read);
 TiffBitmapDecoder decoder = new TiffBitmapDecoder(imageStreamSource, BitmapCreateOptions.None, BitmapCacheOption.Default);
 foreach (BitmapSource bitmapSource in decoder.Frames)
 {
     Bitmap bmp = new Bitmap(bitmapSource.PixelWidth, bitmapSource.PixelHeight, PixelFormat.Format32bppPArgb);
     BitmapData data = bmp.LockBits(new Rectangle(System.Drawing.Point.Empty, bmp.Size), ImageLockMode.WriteOnly, PixelFormat.Format32bppPArgb);
     bitmapSource.CopyPixels(Int32Rect.Empty,  data.Scan0,  data.Height * data.Stride, data.Stride);
     bmp.UnlockBits(data);
     images.Add(bmp);
 }


问:
Google Drive API Error Daily Limit for Unauthenticated Use Exceeded
Im getting error on using Google API.
having right to connect with Google Drive and add new sheet and insert data into it.

It was working till yesterday but when i run the application today.
Im getting error :

Error appears after users given token and tried to access the DRIVE API to get all the files

```<code>domain: "usageLimits"
extendedHelp: "https://code.google.com/apis/console"
message: "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
reason: "dailyLimitExceededUnreg"
</code>```

I have not changed any settings.
Following API are enables for my application access token. Do i have to add / enable more API to make it work.

答:
I was using NodeJS to download a file, but was forgetting to pass the auth.

Initially I was using:

```<code>function downloadFiles() {
  const service = google.drive('v3');
  const dest = fs.createWriteStream('/tmp/foo.csv');
  const fileId = '12345_ID_GOES_HERE';

  service.files.export({
    fileId: fileId,
    mimeType: 'text/csv'
  });
}
</code>```

afterwards, I added an auth argument to the function, and passed it to the export method as well:

```<code>function downloadFiles(auth) {
  const service = google.drive('v3');
  const dest = fs.createWriteStream('/tmp/foo.csv');
  const fileId = '12345_ID_GOES_HERE';

  service.files.export({
    auth: auth,
    fileId: fileId,
    mimeType: 'text/csv'
  })
}
</code>```

I am getting auth by creating an instance of google-auth-library

Body:
Im getting error on using Google API.
having right to connect with Google Drive and add new sheet and insert data into it.

It was working till yesterday but when i run the application today.
Im getting error :

Error appears after users given token and tried to access the DRIVE API to get all the files

domain: "usageLimits"
extendedHelp: "https://code.google.com/apis/console"
message: "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
reason: "dailyLimitExceededUnreg"

I have not changed any settings.
Following API are enables for my application access token. Do i have to add / enable more API to make it work.

Body:
I was using NodeJS to download a file, but was forgetting to pass the auth.

Initially I was using:

function downloadFiles() {
  const service = google.drive('v3');
  const dest = fs.createWriteStream('/tmp/foo.csv');
  const fileId = '12345_ID_GOES_HERE';

  service.files.export({
    fileId: fileId,
    mimeType: 'text/csv'
  });
}

afterwards, I added an auth argument to the function, and passed it to the export method as well:

function downloadFiles(auth) {
  const service = google.drive('v3');
  const dest = fs.createWriteStream('/tmp/foo.csv');
  const fileId = '12345_ID_GOES_HERE';

  service.files.export({
    auth: auth,
    fileId: fileId,
    mimeType: 'text/csv'
  })
}

I am getting auth by creating an instance of google-auth-library


问:
Ionic 2 how to use market templates
I'm new to Ionic 2 and I've discovered templates and theme market, but I don't know how to use it.

Let's say I want to use this template: https://market.ionic.io/starters/event-app-and-maps ; one I've downloaded the zip file, how should I use it? Do I have to create a blank project and then add the downloaded folders in it? If so, is it possible for me to change some of the contents (let's say if I want to use just some of the content offered)?

Same question for themes: how can I integrate them in my project?

答:
First try to understand the app structure and what are the different types of files,folders and what is the use of them etc.. Without that you can not do anything.

Now coming to market themes.. Download the theme and go thru it. Normally most of the developers will provide a how to use guide. Follow  those steps or it will be much better if you implement on your own after understanding the code.

Title: Ionic 2 how to use market templates


问:
WSO2 - Policy Management (XACML) using API
I am studying about XACML and testing polices using WSO2 IS.

I can handle the XACML policies (create, disable, change, etc.) using WSO2 IS API?

Where can I find examples, documentation, etc.?

I found this example [1] in Java (usage WSO2 libs/jars), but my tests are in Python.

[1] https://svn.wso2.org/repos/wso2/people/asela/xacml/pap/5.X.X/src/main/java/org/xacmlinfo/xacml/pap/is/PolicyAdminClient.java

答:
You can handle XACML policies in WSO2 Identity Server through the SOAP API using Python or another programming language.

The WSDL for the API can be retrieved from the URL: https://{ip-address}:{port}/services/EntitlementPolicyAdminService?wsdl

If you are not familiar with WSDL using Python, try to play a little with SOAPUI or Postman. That typically helps to get started with the SOAP API


问:
SVG - animate/move dots along path
I'm looking for a way to move dots along existing path in order to get animation that looks like this:

I was thinking about working with dasharray but wasn't able to get this exact behavior.

Here is an example of something I tried, but as you can see it doesn't really work:

path.link {
  stroke-width: 3px;
  stroke-dasharray: 5 5;
  stroke: black;
}
path.link-anim {
  stroke-width: 3px;
  animation: link-anim 5s linear infinite;
}
path.red {
  stroke: red;
}
path.blue {
  stroke: blue;
}
path.green {
  stroke: green;
}
path.pink {
  stroke: pink;
}
@keyframes link-anim {
    0% {
        stroke-dashoffset: 0;
        stroke-dasharray: 5 5 100%;
    }
    100% {
        stroke-dashoffset: 100%;
        stroke-dasharray: 100% 5 5;
    }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><svg width="450" height="450">
  <g>
    <path class="link" d="M10,10L100,10"></path>
    <path class="link-anim red" d="M10,10L100,10"></path>
  </g>
  <g>
    <path class="link" d="M50,50L200,50"></path>
    <path class="link-anim blue" d="M50,50L200,50"></path>
  </g>
  <g>
    <path class="link" d="M75,75L75,200"></path>
    <path class="link-anim green" d="M75,75L75,200"></path>
  </g>
  <g>
    <path class="link" d="M85,85L450,450"></path>
    <path class="link-anim pink" d="M85,85L450,450"></path>
  </g>
</svg></code>```

Note - the angle of the line is not something I care about. I should have written this from the start. What I need is the 3 dots to move forward (and only those 3 dots).

答:
a <path> has a d attribute with x, y points in it.

all you have to do is loop over those points and set the current one to a circle's cx and cy

the points will need to be cleaned before.

have a look at the Demo

Title: SVG - animate/move dots along path

Body:
I'm looking for a way to move dots along existing path in order to get animation that looks like this:

I was thinking about working with dasharray but wasn't able to get this exact behavior.

Here is an example of something I tried, but as you can see it doesn't really work:

path.link {
  stroke-width: 3px;
  stroke-dasharray: 5 5;
  stroke: black;
}
path.link-anim {
  stroke-width: 3px;
  animation: link-anim 5s linear infinite;
}
path.red {
  stroke: red;
}
path.blue {
  stroke: blue;
}
path.green {
  stroke: green;
}
path.pink {
  stroke: pink;
}
@keyframes link-anim {
    0% {
        stroke-dashoffset: 0;
        stroke-dasharray: 5 5 100%;
    }
    100% {
        stroke-dashoffset: 100%;
        stroke-dasharray: 100% 5 5;
    }
}

<svg width="450" height="450">
  <g>
    <path class="link" d="M10,10L100,10"></path>
    <path class="link-anim red" d="M10,10L100,10"></path>
  </g>
  <g>
    <path class="link" d="M50,50L200,50"></path>
    <path class="link-anim blue" d="M50,50L200,50"></path>
  </g>
  <g>
    <path class="link" d="M75,75L75,200"></path>
    <path class="link-anim green" d="M75,75L75,200"></path>
  </g>
  <g>
    <path class="link" d="M85,85L450,450"></path>
    <path class="link-anim pink" d="M85,85L450,450"></path>
  </g>
</svg>

Note - the angle of the line is not something I care about. I should have written this from the start. What I need is the 3 dots to move forward (and only those 3 dots).


问:
Visual Studio 2017 makes ding noise and does nothing
I upgraded VS from VS 2017 RC to VS 2017 and I have noticed that when I try to start it up that it just makes the Windows Ding sound and nothing happens. </p>

答:
I would uninstall Visual Studio with the visual studio uninstaller on github and then reinstall.

Sounds like the upgrade did not work right

https://github.com/Microsoft/VisualStudioUninstaller


问:
Woocommerce - Move titles over thumbnails of products in Category page
I need to move the titles of the products, while I am browsing the category page, over their thumbnails

Details:

I have created a shop page where I only display the categories.
Every category contains 1 to 10 products.

Once I click a category, I land on a page where I see all of the products in that category.

I would like to see the titles of those products appearing over their thumbnails.

Thank you

答:
If you put code into a plugin, you must wait for WooCommerce loading:</p>

```<code>add_action('plugins_loaded', function()
{
    // move product's title before product thumbnail instead of next to that
    remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_title', 5);
    add_action('woocommerce_before_single_product_summary', 'woocommerce_template_single_title');
}
</code>```

Body:
If you put code into a plugin, you must wait for WooCommerce loading:

add_action('plugins_loaded', function()
{
    // move product's title before product thumbnail instead of next to that
    remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_title', 5);
    add_action('woocommerce_before_single_product_summary', 'woocommerce_template_single_title');
}


问:
TensorFlow: Blas GEMM launch failed
When I'm trying to use TensorFlow with Keras using the gpu, I'm getting this error message:

```<code>C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\__main__.py:2: UserWarning: Update your `fit_generator` call to the Keras 2 API: `fit_generator(<keras.pre..., 37800, epochs=2, validation_data=<keras.pre..., validation_steps=4200)`
  from ipykernel import kernelapp as app

Epoch 1/2

InternalError                             Traceback (most recent call last)
C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _do_call(self, fn, *args)
   1038     try:
-> 1039       return fn(*args)
   1040     except errors.OpError as e:

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _run_fn(session, feed_dict, fetch_list, target_list, options, run_metadata)
   1020                                  feed_dict, fetch_list, target_list,
-> 1021                                  status, run_metadata)
   1022

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\contextlib.py in __exit__(self, type, value, traceback)
     65             try:
---> 66                 next(self.gen)
     67             except StopIteration:

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\errors_impl.py in raise_exception_on_not_ok_status()
    465           compat.as_text(pywrap_tensorflow.TF_Message(status)),
--> 466           pywrap_tensorflow.TF_GetCode(status))
    467   finally:

InternalError: Blas GEMM launch failed : a.shape=(64, 784), b.shape=(784, 10), m=64, n=10, k=784
     [[Node: dense_1/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/gpu:0"](flatten_1/Reshape, dense_1/kernel/read)]]

During handling of the above exception, another exception occurred:

InternalError                             Traceback (most recent call last)
<ipython-input-13-2a52d1079a66> in <module>()
      1 history=model.fit_generator(batches, batches.n, nb_epoch=2,
----> 2                     validation_data=val_batches, nb_val_samples=val_batches.n)

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\legacy\interfaces.py in wrapper(*args, **kwargs)
     86                 warnings.warn('Update your `' + object_name +
     87                               '` call to the Keras 2 API: ' + signature, stacklevel=2)
---> 88             return func(*args, **kwargs)
     89         wrapper._legacy_support_signature = inspect.getargspec(func)
     90         return wrapper

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\models.py in fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, class_weight, max_q_size, workers, pickle_safe, initial_epoch)
   1108                                         workers=workers,
   1109                                         pickle_safe=pickle_safe,
-> 1110                                         initial_epoch=initial_epoch)
   1111
   1112     @interfaces.legacy_generator_methods_support

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\legacy\interfaces.py in wrapper(*args, **kwargs)
     86                 warnings.warn('Update your `' + object_name +
     87                               '` call to the Keras 2 API: ' + signature, stacklevel=2)
---> 88             return func(*args, **kwargs)
     89         wrapper._legacy_support_signature = inspect.getargspec(func)
     90         return wrapper

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\engine\training.py in fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, class_weight, max_q_size, workers, pickle_safe, initial_epoch)
   1888                     outs = self.train_on_batch(x, y,
   1889                                                sample_weight=sample_weight,
-> 1890                                                class_weight=class_weight)
   1891
   1892                     if not isinstance(outs, list):

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\engine\training.py in train_on_batch(self, x, y, sample_weight, class_weight)
   1631             ins = x + y + sample_weights
   1632         self._make_train_function()
-> 1633         outputs = self.train_function(ins)
   1634         if len(outputs) == 1:
   1635             return outputs[0]

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\backend\tensorflow_backend.py in __call__(self, inputs)
   2227         session = get_session()
   2228         updated = session.run(self.outputs + [self.updates_op],
-> 2229                               feed_dict=feed_dict)
   2230         return updated[:len(self.outputs)]
   2231

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in run(self, fetches, feed_dict, options, run_metadata)
    776     try:
    777       result = self._run(None, fetches, feed_dict, options_ptr,
--> 778                          run_metadata_ptr)
    779       if run_metadata:
    780         proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
    980     if final_fetches or final_targets:
    981       results = self._do_run(handle, final_targets, final_fetches,
--> 982                              feed_dict_string, options, run_metadata)
    983     else:
    984       results = []

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata)
   1030     if handle is None:
   1031       return self._do_call(_run_fn, self._session, feed_dict, fetch_list,
-> 1032                            target_list, options, run_metadata)
   1033     else:
   1034       return self._do_call(_prun_fn, self._session, handle, feed_dict,

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _do_call(self, fn, *args)
   1050         except KeyError:
   1051           pass
-> 1052       raise type(e)(node_def, op, message)
   1053
   1054   def _extend_graph(self):

InternalError: Blas GEMM launch failed : a.shape=(64, 784), b.shape=(784, 10), m=64, n=10, k=784
     [[Node: dense_1/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/gpu:0"](flatten_1/Reshape, dense_1/kernel/read)]]

Caused by op 'dense_1/MatMul', defined at:
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\__main__.py", line 3, in <module>
    app.launch_new_instance()
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\traitlets\config\application.py", line 658, in launch_instance
    app.start()
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\kernelapp.py", line 477, in start
    ioloop.IOLoop.instance().start()
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\zmq\eventloop\ioloop.py", line 177, in start
    super(ZMQIOLoop, self).start()
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tornado\ioloop.py", line 888, in start
    handler_func(fd_obj, events)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tornado\stack_context.py", line 277, in null_wrapper
    return fn(*args, **kwargs)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\zmq\eventloop\zmqstream.py", line 440, in _handle_events
    self._handle_recv()
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\zmq\eventloop\zmqstream.py", line 472, in _handle_recv
    self._run_callback(callback, msg)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\zmq\eventloop\zmqstream.py", line 414, in _run_callback
    callback(*args, **kwargs)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tornado\stack_context.py", line 277, in null_wrapper
    return fn(*args, **kwargs)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\kernelbase.py", line 283, in dispatcher
    return self.dispatch_shell(stream, msg)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\kernelbase.py", line 235, in dispatch_shell
    handler(stream, idents, msg)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\kernelbase.py", line 399, in execute_request
    user_expressions, allow_stdin)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\ipkernel.py", line 196, in do_execute
    res = shell.run_cell(code, store_history=store_history, silent=silent)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\zmqshell.py", line 533, in run_cell
    return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\IPython\core\interactiveshell.py", line 2683, in run_cell
    interactivity=interactivity, compiler=compiler, result=result)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\IPython\core\interactiveshell.py", line 2787, in run_ast_nodes
    if self.run_code(code, result):
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\IPython\core\interactiveshell.py", line 2847, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-10-1e7a3b259f23>", line 4, in <module>
    model.add(Dense(10, activation='softmax'))
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\models.py", line 466, in add
    output_tensor = layer(self.outputs[0])
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\engine\topology.py", line 585, in __call__
    output = self.call(inputs, **kwargs)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\layers\core.py", line 840, in call
    output = K.dot(inputs, self.kernel)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\backend\tensorflow_backend.py", line 936, in dot
    out = tf.matmul(x, y)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\ops\math_ops.py", line 1801, in matmul
    a, b, transpose_a=transpose_a, transpose_b=transpose_b, name=name)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\ops\gen_math_ops.py", line 1263, in _mat_mul
    transpose_b=transpose_b, name=name)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 768, in apply_op
    op_def=op_def)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 2336, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 1228, in __init__
    self._traceback = _extract_stack()

InternalError (see above for traceback): Blas GEMM launch failed : a.shape=(64, 784), b.shape=(784, 10), m=64, n=10, k=784
     [[Node: dense_1/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/gpu:0"](flatten_1/Reshape, dense_1/kernel/read)]]
</code>```

When I'm trying to use TensorFlow with Keras using the cpu, I'm getting this error message:

```<code>C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\__main__.py:5: UserWarning: Update your `fit_generator` call to the Keras 2 API: `fit_generator(<keras.pre..., 37800, validation_steps=4200, validation_data=<keras.pre..., epochs=2)`
Epoch 1/2
---------------------------------------------------------------------------
InternalError                             Traceback (most recent call last)
C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _do_call(self, fn, *args)
   1038     try:
-> 1039       return fn(*args)
   1040     except errors.OpError as e:

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _run_fn(session, feed_dict, fetch_list, target_list, options, run_metadata)
   1020                                  feed_dict, fetch_list, target_list,
-> 1021                                  status, run_metadata)
   1022

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\contextlib.py in __exit__(self, type, value, traceback)
     65             try:
---> 66                 next(self.gen)
     67             except StopIteration:

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\errors_impl.py in raise_exception_on_not_ok_status()
    465           compat.as_text(pywrap_tensorflow.TF_Message(status)),
--> 466           pywrap_tensorflow.TF_GetCode(status))
    467   finally:

InternalError: Blas GEMM launch failed : a.shape=(64, 784), b.shape=(784, 10), m=64, n=10, k=784
     [[Node: dense_1/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/gpu:0"](flatten_1/Reshape, dense_1/kernel/read)]]
     [[Node: Assign_3/_84 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_374_Assign_3", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

During handling of the above exception, another exception occurred:

InternalError                             Traceback (most recent call last)
<ipython-input-14-f66b4d3d5b88> in <module>()
      3 with tf.device('/cpu:0'):
      4     history=model.fit_generator(batches, batches.n, nb_epoch=2,
----> 5                     validation_data=val_batches, nb_val_samples=val_batches.n)

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\legacy\interfaces.py in wrapper(*args, **kwargs)
     86                 warnings.warn('Update your `' + object_name +
     87                               '` call to the Keras 2 API: ' + signature, stacklevel=2)
---> 88             return func(*args, **kwargs)
     89         wrapper._legacy_support_signature = inspect.getargspec(func)
     90         return wrapper

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\models.py in fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, class_weight, max_q_size, workers, pickle_safe, initial_epoch)
   1108                                         workers=workers,
   1109                                         pickle_safe=pickle_safe,
-> 1110                                         initial_epoch=initial_epoch)
   1111
   1112     @interfaces.legacy_generator_methods_support

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\legacy\interfaces.py in wrapper(*args, **kwargs)
     86                 warnings.warn('Update your `' + object_name +
     87                               '` call to the Keras 2 API: ' + signature, stacklevel=2)
---> 88             return func(*args, **kwargs)
     89         wrapper._legacy_support_signature = inspect.getargspec(func)
     90         return wrapper

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\engine\training.py in fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, class_weight, max_q_size, workers, pickle_safe, initial_epoch)
   1888                     outs = self.train_on_batch(x, y,
   1889                                                sample_weight=sample_weight,
-> 1890                                                class_weight=class_weight)
   1891
   1892                     if not isinstance(outs, list):

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\engine\training.py in train_on_batch(self, x, y, sample_weight, class_weight)
   1631             ins = x + y + sample_weights
   1632         self._make_train_function()
-> 1633         outputs = self.train_function(ins)
   1634         if len(outputs) == 1:
   1635             return outputs[0]

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\backend\tensorflow_backend.py in __call__(self, inputs)
   2227         session = get_session()
   2228         updated = session.run(self.outputs + [self.updates_op],
-> 2229                               feed_dict=feed_dict)
   2230         return updated[:len(self.outputs)]
   2231

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in run(self, fetches, feed_dict, options, run_metadata)
    776     try:
    777       result = self._run(None, fetches, feed_dict, options_ptr,
--> 778                          run_metadata_ptr)
    779       if run_metadata:
    780         proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
    980     if final_fetches or final_targets:
    981       results = self._do_run(handle, final_targets, final_fetches,
--> 982                              feed_dict_string, options, run_metadata)
    983     else:
    984       results = []

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata)
   1030     if handle is None:
   1031       return self._do_call(_run_fn, self._session, feed_dict, fetch_list,
-> 1032                            target_list, options, run_metadata)
   1033     else:
   1034       return self._do_call(_prun_fn, self._session, handle, feed_dict,

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _do_call(self, fn, *args)
   1050         except KeyError:
   1051           pass
-> 1052       raise type(e)(node_def, op, message)
   1053
   1054   def _extend_graph(self):

InternalError: Blas GEMM launch failed : a.shape=(64, 784), b.shape=(784, 10), m=64, n=10, k=784
     [[Node: dense_1/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/gpu:0"](flatten_1/Reshape, dense_1/kernel/read)]]
     [[Node: Assign_3/_84 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_374_Assign_3", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

Caused by op 'dense_1/MatMul', defined at:
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\__main__.py", line 3, in <module>
    app.launch_new_instance()
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\traitlets\config\application.py", line 658, in launch_instance
    app.start()
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\kernelapp.py", line 477, in start
    ioloop.IOLoop.instance().start()
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\zmq\eventloop\ioloop.py", line 177, in start
    super(ZMQIOLoop, self).start()
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tornado\ioloop.py", line 888, in start
    handler_func(fd_obj, events)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tornado\stack_context.py", line 277, in null_wrapper
    return fn(*args, **kwargs)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\zmq\eventloop\zmqstream.py", line 440, in _handle_events
    self._handle_recv()
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\zmq\eventloop\zmqstream.py", line 472, in _handle_recv
    self._run_callback(callback, msg)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\zmq\eventloop\zmqstream.py", line 414, in _run_callback
    callback(*args, **kwargs)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tornado\stack_context.py", line 277, in null_wrapper
    return fn(*args, **kwargs)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\kernelbase.py", line 283, in dispatcher
    return self.dispatch_shell(stream, msg)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\kernelbase.py", line 235, in dispatch_shell
    handler(stream, idents, msg)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\kernelbase.py", line 399, in execute_request
    user_expressions, allow_stdin)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\ipkernel.py", line 196, in do_execute
    res = shell.run_cell(code, store_history=store_history, silent=silent)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\zmqshell.py", line 533, in run_cell
    return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\IPython\core\interactiveshell.py", line 2683, in run_cell
    interactivity=interactivity, compiler=compiler, result=result)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\IPython\core\interactiveshell.py", line 2787, in run_ast_nodes
    if self.run_code(code, result):
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\IPython\core\interactiveshell.py", line 2847, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-12-1e7a3b259f23>", line 4, in <module>
    model.add(Dense(10, activation='softmax'))
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\models.py", line 466, in add
    output_tensor = layer(self.outputs[0])
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\engine\topology.py", line 585, in __call__
    output = self.call(inputs, **kwargs)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\layers\core.py", line 840, in call
    output = K.dot(inputs, self.kernel)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\backend\tensorflow_backend.py", line 936, in dot
    out = tf.matmul(x, y)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\ops\math_ops.py", line 1801, in matmul
    a, b, transpose_a=transpose_a, transpose_b=transpose_b, name=name)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\ops\gen_math_ops.py", line 1263, in _mat_mul
    transpose_b=transpose_b, name=name)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 768, in apply_op
    op_def=op_def)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 2336, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 1228, in __init__
    self._traceback = _extract_stack()

InternalError (see above for traceback): Blas GEMM launch failed : a.shape=(64, 784), b.shape=(784, 10), m=64, n=10, k=784
     [[Node: dense_1/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/gpu:0"](flatten_1/Reshape, dense_1/kernel/read)]]
     [[Node: Assign_3/_84 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_374_Assign_3", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]
</code>```

In both cases, the error is with
    InternalError (see above for traceback): Blas GEMM launch failed
Can you tell me how to get Blas GEMM to launch?
I installed tensorflow and keras in a 3.5 python anaconda environment where I also installed all needed module (numpy, pandas, scipy, scikit-learn). I have a Windows 10 with a NVIDIA gpu that can use CUDA. I downloaded CUDA and cuDNN. I'm using the Jupyter notebook on Chrome.

Sometimes when I run my code, rather than having this error, I get that it starts running and then it crashes. After the crash, I can't do anything on my jupyter notebook and after some time a pop-up asks me if I want to kill the page. This is an image of what I got after the crash.
!(http://www.hostingpics.net/viewer.php?id=647186tensorflowError.png)

P.S. I know my problem is similar as in this question:
Tensorflow Basic Example Error: CUBLAS_STATUS_NOT_INITIALIZED
but it has not been solved there and I'm not sure this question is clear enough or is exactly the same problem as I have so I'm posting it with my own error message.
This problem is different of:
TensorFlow: InternalError: Blas SGEMM launch failed
Since I have a problem with GEMM rather than SGEMM and that my problem is both with gpu and cpu and it is not solved by the answer of this question.

答: Had the same error. Maybe it is related to the problem that tensorflow is allocating all gpu memory. But the fix recommended there didn't work for me and it is not possible yet to limit tensorflow's gpu memory use via keras.json or commandline. Switching keras' backend to Theano resolved the issue for me (howto can be found here).  </p>

Title: TensorFlow: Blas GEMM launch failed

Body:
When I'm trying to use TensorFlow with Keras using the gpu, I'm getting this error message:

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\__main__.py:2: UserWarning: Update your `fit_generator` call to the Keras 2 API: `fit_generator(<keras.pre..., 37800, epochs=2, validation_data=<keras.pre..., validation_steps=4200)`
  from ipykernel import kernelapp as app

Epoch 1/2

InternalError                             Traceback (most recent call last)
C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _do_call(self, fn, *args)
   1038     try:
-> 1039       return fn(*args)
   1040     except errors.OpError as e:

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _run_fn(session, feed_dict, fetch_list, target_list, options, run_metadata)
   1020                                  feed_dict, fetch_list, target_list,
-> 1021                                  status, run_metadata)
   1022

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\contextlib.py in __exit__(self, type, value, traceback)
     65             try:
---> 66                 next(self.gen)
     67             except StopIteration:

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\errors_impl.py in raise_exception_on_not_ok_status()
    465           compat.as_text(pywrap_tensorflow.TF_Message(status)),
--> 466           pywrap_tensorflow.TF_GetCode(status))
    467   finally:

InternalError: Blas GEMM launch failed : a.shape=(64, 784), b.shape=(784, 10), m=64, n=10, k=784
     [[Node: dense_1/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/gpu:0"](flatten_1/Reshape, dense_1/kernel/read)]]

During handling of the above exception, another exception occurred:

InternalError                             Traceback (most recent call last)
<ipython-input-13-2a52d1079a66> in <module>()
      1 history=model.fit_generator(batches, batches.n, nb_epoch=2,
----> 2                     validation_data=val_batches, nb_val_samples=val_batches.n)

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\legacy\interfaces.py in wrapper(*args, **kwargs)
     86                 warnings.warn('Update your `' + object_name +
     87                               '` call to the Keras 2 API: ' + signature, stacklevel=2)
---> 88             return func(*args, **kwargs)
     89         wrapper._legacy_support_signature = inspect.getargspec(func)
     90         return wrapper

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\models.py in fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, class_weight, max_q_size, workers, pickle_safe, initial_epoch)
   1108                                         workers=workers,
   1109                                         pickle_safe=pickle_safe,
-> 1110                                         initial_epoch=initial_epoch)
   1111
   1112     @interfaces.legacy_generator_methods_support

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\legacy\interfaces.py in wrapper(*args, **kwargs)
     86                 warnings.warn('Update your `' + object_name +
     87                               '` call to the Keras 2 API: ' + signature, stacklevel=2)
---> 88             return func(*args, **kwargs)
     89         wrapper._legacy_support_signature = inspect.getargspec(func)
     90         return wrapper

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\engine\training.py in fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, class_weight, max_q_size, workers, pickle_safe, initial_epoch)
   1888                     outs = self.train_on_batch(x, y,
   1889                                                sample_weight=sample_weight,
-> 1890                                                class_weight=class_weight)
   1891
   1892                     if not isinstance(outs, list):

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\engine\training.py in train_on_batch(self, x, y, sample_weight, class_weight)
   1631             ins = x + y + sample_weights
   1632         self._make_train_function()
-> 1633         outputs = self.train_function(ins)
   1634         if len(outputs) == 1:
   1635             return outputs[0]

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\backend\tensorflow_backend.py in __call__(self, inputs)
   2227         session = get_session()
   2228         updated = session.run(self.outputs + [self.updates_op],
-> 2229                               feed_dict=feed_dict)
   2230         return updated[:len(self.outputs)]
   2231

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in run(self, fetches, feed_dict, options, run_metadata)
    776     try:
    777       result = self._run(None, fetches, feed_dict, options_ptr,
--> 778                          run_metadata_ptr)
    779       if run_metadata:
    780         proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
    980     if final_fetches or final_targets:
    981       results = self._do_run(handle, final_targets, final_fetches,
--> 982                              feed_dict_string, options, run_metadata)
    983     else:
    984       results = []

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata)
   1030     if handle is None:
   1031       return self._do_call(_run_fn, self._session, feed_dict, fetch_list,
-> 1032                            target_list, options, run_metadata)
   1033     else:
   1034       return self._do_call(_prun_fn, self._session, handle, feed_dict,

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _do_call(self, fn, *args)
   1050         except KeyError:
   1051           pass
-> 1052       raise type(e)(node_def, op, message)
   1053
   1054   def _extend_graph(self):

InternalError: Blas GEMM launch failed : a.shape=(64, 784), b.shape=(784, 10), m=64, n=10, k=784
     [[Node: dense_1/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/gpu:0"](flatten_1/Reshape, dense_1/kernel/read)]]

Caused by op 'dense_1/MatMul', defined at:
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\__main__.py", line 3, in <module>
    app.launch_new_instance()
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\traitlets\config\application.py", line 658, in launch_instance
    app.start()
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\kernelapp.py", line 477, in start
    ioloop.IOLoop.instance().start()
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\zmq\eventloop\ioloop.py", line 177, in start
    super(ZMQIOLoop, self).start()
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tornado\ioloop.py", line 888, in start
    handler_func(fd_obj, events)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tornado\stack_context.py", line 277, in null_wrapper
    return fn(*args, **kwargs)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\zmq\eventloop\zmqstream.py", line 440, in _handle_events
    self._handle_recv()
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\zmq\eventloop\zmqstream.py", line 472, in _handle_recv
    self._run_callback(callback, msg)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\zmq\eventloop\zmqstream.py", line 414, in _run_callback
    callback(*args, **kwargs)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tornado\stack_context.py", line 277, in null_wrapper
    return fn(*args, **kwargs)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\kernelbase.py", line 283, in dispatcher
    return self.dispatch_shell(stream, msg)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\kernelbase.py", line 235, in dispatch_shell
    handler(stream, idents, msg)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\kernelbase.py", line 399, in execute_request
    user_expressions, allow_stdin)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\ipkernel.py", line 196, in do_execute
    res = shell.run_cell(code, store_history=store_history, silent=silent)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\zmqshell.py", line 533, in run_cell
    return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\IPython\core\interactiveshell.py", line 2683, in run_cell
    interactivity=interactivity, compiler=compiler, result=result)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\IPython\core\interactiveshell.py", line 2787, in run_ast_nodes
    if self.run_code(code, result):
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\IPython\core\interactiveshell.py", line 2847, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-10-1e7a3b259f23>", line 4, in <module>
    model.add(Dense(10, activation='softmax'))
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\models.py", line 466, in add
    output_tensor = layer(self.outputs[0])
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\engine\topology.py", line 585, in __call__
    output = self.call(inputs, **kwargs)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\layers\core.py", line 840, in call
    output = K.dot(inputs, self.kernel)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\backend\tensorflow_backend.py", line 936, in dot
    out = tf.matmul(x, y)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\ops\math_ops.py", line 1801, in matmul
    a, b, transpose_a=transpose_a, transpose_b=transpose_b, name=name)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\ops\gen_math_ops.py", line 1263, in _mat_mul
    transpose_b=transpose_b, name=name)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 768, in apply_op
    op_def=op_def)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 2336, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 1228, in __init__
    self._traceback = _extract_stack()

InternalError (see above for traceback): Blas GEMM launch failed : a.shape=(64, 784), b.shape=(784, 10), m=64, n=10, k=784
     [[Node: dense_1/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/gpu:0"](flatten_1/Reshape, dense_1/kernel/read)]]

When I'm trying to use TensorFlow with Keras using the cpu, I'm getting this error message:

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\__main__.py:5: UserWarning: Update your `fit_generator` call to the Keras 2 API: `fit_generator(<keras.pre..., 37800, validation_steps=4200, validation_data=<keras.pre..., epochs=2)`
Epoch 1/2
---------------------------------------------------------------------------
InternalError                             Traceback (most recent call last)
C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _do_call(self, fn, *args)
   1038     try:
-> 1039       return fn(*args)
   1040     except errors.OpError as e:

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _run_fn(session, feed_dict, fetch_list, target_list, options, run_metadata)
   1020                                  feed_dict, fetch_list, target_list,
-> 1021                                  status, run_metadata)
   1022

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\contextlib.py in __exit__(self, type, value, traceback)
     65             try:
---> 66                 next(self.gen)
     67             except StopIteration:

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\errors_impl.py in raise_exception_on_not_ok_status()
    465           compat.as_text(pywrap_tensorflow.TF_Message(status)),
--> 466           pywrap_tensorflow.TF_GetCode(status))
    467   finally:

InternalError: Blas GEMM launch failed : a.shape=(64, 784), b.shape=(784, 10), m=64, n=10, k=784
     [[Node: dense_1/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/gpu:0"](flatten_1/Reshape, dense_1/kernel/read)]]
     [[Node: Assign_3/_84 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_374_Assign_3", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

During handling of the above exception, another exception occurred:

InternalError                             Traceback (most recent call last)
<ipython-input-14-f66b4d3d5b88> in <module>()
      3 with tf.device('/cpu:0'):
      4     history=model.fit_generator(batches, batches.n, nb_epoch=2,
----> 5                     validation_data=val_batches, nb_val_samples=val_batches.n)

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\legacy\interfaces.py in wrapper(*args, **kwargs)
     86                 warnings.warn('Update your `' + object_name +
     87                               '` call to the Keras 2 API: ' + signature, stacklevel=2)
---> 88             return func(*args, **kwargs)
     89         wrapper._legacy_support_signature = inspect.getargspec(func)
     90         return wrapper

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\models.py in fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, class_weight, max_q_size, workers, pickle_safe, initial_epoch)
   1108                                         workers=workers,
   1109                                         pickle_safe=pickle_safe,
-> 1110                                         initial_epoch=initial_epoch)
   1111
   1112     @interfaces.legacy_generator_methods_support

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\legacy\interfaces.py in wrapper(*args, **kwargs)
     86                 warnings.warn('Update your `' + object_name +
     87                               '` call to the Keras 2 API: ' + signature, stacklevel=2)
---> 88             return func(*args, **kwargs)
     89         wrapper._legacy_support_signature = inspect.getargspec(func)
     90         return wrapper

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\engine\training.py in fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, class_weight, max_q_size, workers, pickle_safe, initial_epoch)
   1888                     outs = self.train_on_batch(x, y,
   1889                                                sample_weight=sample_weight,
-> 1890                                                class_weight=class_weight)
   1891
   1892                     if not isinstance(outs, list):

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\engine\training.py in train_on_batch(self, x, y, sample_weight, class_weight)
   1631             ins = x + y + sample_weights
   1632         self._make_train_function()
-> 1633         outputs = self.train_function(ins)
   1634         if len(outputs) == 1:
   1635             return outputs[0]

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\backend\tensorflow_backend.py in __call__(self, inputs)
   2227         session = get_session()
   2228         updated = session.run(self.outputs + [self.updates_op],
-> 2229                               feed_dict=feed_dict)
   2230         return updated[:len(self.outputs)]
   2231

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in run(self, fetches, feed_dict, options, run_metadata)
    776     try:
    777       result = self._run(None, fetches, feed_dict, options_ptr,
--> 778                          run_metadata_ptr)
    779       if run_metadata:
    780         proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
    980     if final_fetches or final_targets:
    981       results = self._do_run(handle, final_targets, final_fetches,
--> 982                              feed_dict_string, options, run_metadata)
    983     else:
    984       results = []

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata)
   1030     if handle is None:
   1031       return self._do_call(_run_fn, self._session, feed_dict, fetch_list,
-> 1032                            target_list, options, run_metadata)
   1033     else:
   1034       return self._do_call(_prun_fn, self._session, handle, feed_dict,

C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _do_call(self, fn, *args)
   1050         except KeyError:
   1051           pass
-> 1052       raise type(e)(node_def, op, message)
   1053
   1054   def _extend_graph(self):

InternalError: Blas GEMM launch failed : a.shape=(64, 784), b.shape=(784, 10), m=64, n=10, k=784
     [[Node: dense_1/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/gpu:0"](flatten_1/Reshape, dense_1/kernel/read)]]
     [[Node: Assign_3/_84 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_374_Assign_3", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

Caused by op 'dense_1/MatMul', defined at:
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\__main__.py", line 3, in <module>
    app.launch_new_instance()
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\traitlets\config\application.py", line 658, in launch_instance
    app.start()
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\kernelapp.py", line 477, in start
    ioloop.IOLoop.instance().start()
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\zmq\eventloop\ioloop.py", line 177, in start
    super(ZMQIOLoop, self).start()
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tornado\ioloop.py", line 888, in start
    handler_func(fd_obj, events)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tornado\stack_context.py", line 277, in null_wrapper
    return fn(*args, **kwargs)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\zmq\eventloop\zmqstream.py", line 440, in _handle_events
    self._handle_recv()
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\zmq\eventloop\zmqstream.py", line 472, in _handle_recv
    self._run_callback(callback, msg)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\zmq\eventloop\zmqstream.py", line 414, in _run_callback
    callback(*args, **kwargs)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tornado\stack_context.py", line 277, in null_wrapper
    return fn(*args, **kwargs)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\kernelbase.py", line 283, in dispatcher
    return self.dispatch_shell(stream, msg)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\kernelbase.py", line 235, in dispatch_shell
    handler(stream, idents, msg)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\kernelbase.py", line 399, in execute_request
    user_expressions, allow_stdin)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\ipkernel.py", line 196, in do_execute
    res = shell.run_cell(code, store_history=store_history, silent=silent)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\zmqshell.py", line 533, in run_cell
    return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\IPython\core\interactiveshell.py", line 2683, in run_cell
    interactivity=interactivity, compiler=compiler, result=result)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\IPython\core\interactiveshell.py", line 2787, in run_ast_nodes
    if self.run_code(code, result):
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\IPython\core\interactiveshell.py", line 2847, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-12-1e7a3b259f23>", line 4, in <module>
    model.add(Dense(10, activation='softmax'))
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\models.py", line 466, in add
    output_tensor = layer(self.outputs[0])
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\engine\topology.py", line 585, in __call__
    output = self.call(inputs, **kwargs)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\layers\core.py", line 840, in call
    output = K.dot(inputs, self.kernel)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\keras\backend\tensorflow_backend.py", line 936, in dot
    out = tf.matmul(x, y)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\ops\math_ops.py", line 1801, in matmul
    a, b, transpose_a=transpose_a, transpose_b=transpose_b, name=name)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\ops\gen_math_ops.py", line 1263, in _mat_mul
    transpose_b=transpose_b, name=name)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 768, in apply_op
    op_def=op_def)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 2336, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 1228, in __init__
    self._traceback = _extract_stack()

InternalError (see above for traceback): Blas GEMM launch failed : a.shape=(64, 784), b.shape=(784, 10), m=64, n=10, k=784
     [[Node: dense_1/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/gpu:0"](flatten_1/Reshape, dense_1/kernel/read)]]
     [[Node: Assign_3/_84 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_374_Assign_3", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

In both cases, the error is with
    InternalError (see above for traceback): Blas GEMM launch failed
Can you tell me how to get Blas GEMM to launch?
I installed tensorflow and keras in a 3.5 python anaconda environment where I also installed all needed module (numpy, pandas, scipy, scikit-learn). I have a Windows 10 with a NVIDIA gpu that can use CUDA. I downloaded CUDA and cuDNN. I'm using the Jupyter notebook on Chrome.

Sometimes when I run my code, rather than having this error, I get that it starts running and then it crashes. After the crash, I can't do anything on my jupyter notebook and after some time a pop-up asks me if I want to kill the page. This is an image of what I got after the crash.
!(http://www.hostingpics.net/viewer.php?id=647186tensorflowError.png)

P.S. I know my problem is similar as in this question:
Tensorflow Basic Example Error: CUBLAS_STATUS_NOT_INITIALIZED
but it has not been solved there and I'm not sure this question is clear enough or is exactly the same problem as I have so I'm posting it with my own error message.
This problem is different of:
TensorFlow: InternalError: Blas SGEMM launch failed
Since I have a problem with GEMM rather than SGEMM and that my problem is both with gpu and cpu and it is not solved by the answer of this question.


问:
How to define free-variable in python?
The local/global/free variable definitions from python doc:

If a name is bound in a block, it is a local variable of that block, unless declared as nonlocal. If a name is bound at the module level, it is a global variable. (The variables of the module code block are local and global.) If a variable is used in a code block but not defined there, it is a free variable.

Code 1:

```<code>>>> x = 0
>>> def foo():
...   print(x)
...   print(locals())
...
>>> foo()
0
{}
</code>```

Code 2:

```<code>>>> def bar():
...   x = 1
...   def foo():
...     print(x)
...     print(locals())
...   foo()
...
>>> bar()
1
{'x':1}
</code>```

Free variables are returned by locals() when it is called in function blocks, but not in class blocks.

In Code 1, x is a global variable, and it's used but not defined in foo().

However it's not a free variable, because it's not returned by locals().

I think it's not what the doc said. Is there a technical definition for free variable?

答:
There is no explicit keyword to declare a free variable in Python. Based on the definition of a function and the statements inside and surrounding it, Python will classify variables into bound, cell and free variables.

The following example illustrates this concept using the function's code object which encapsulates the variables mentioned in the previous paragraph.

```<code>def func(arg1, arg2=2):
    def inner_func(arg3=arg2):
        return arg1, arg3
    arg1, arg2 = None
    return inner_func
</code>```

For 'func':

• arg1 and arg2 are bound variables

• arg1 is a cell variable since it is a free variable inside of 'inner_func'

• There are no free variables.

```<code>func.__code__.co_varnames
</code>```

('arg1', 'arg2', 'inner_func')

```<code>func.__code__.co_cellvars
</code>```

('arg1',)

```<code>func.__code__.co_freevars
</code>```

()

For 'inner_func':

• arg3 is a bound variable

• arg1 is a free variable

• There are no cell variables

```<code>inner_func.__code__.co_varnames
</code>```

('arg3',)

```<code>inner_func.__code__.co_freevars
</code>```

('arg1')

```<code>inner_func.__code__.co_cellvars
</code>```

()

Title: How to define free-variable in python?

Body:
The local/global/free variable definitions from python doc:

If a name is bound in a block, it is a local variable of that block, unless declared as nonlocal. If a name is bound at the module level, it is a global variable. (The variables of the module code block are local and global.) If a variable is used in a code block but not defined there, it is a free variable.

Code 1:

>>> x = 0
>>> def foo():
...   print(x)
...   print(locals())
...
>>> foo()
0
{}

Code 2:

>>> def bar():
...   x = 1
...   def foo():
...     print(x)
...     print(locals())
...   foo()
...
>>> bar()
1
{'x':1}

Free variables are returned by locals() when it is called in function blocks, but not in class blocks.

In Code 1, x is a global variable, and it's used but not defined in foo().

However it's not a free variable, because it's not returned by locals().

I think it's not what the doc said. Is there a technical definition for free variable?

Body:
There is no explicit keyword to declare a free variable in Python. Based on the definition of a function and the statements inside and surrounding it, Python will classify variables into bound, cell and free variables.

The following example illustrates this concept using the function's code object which encapsulates the variables mentioned in the previous paragraph.

def func(arg1, arg2=2):
    def inner_func(arg3=arg2):
        return arg1, arg3
    arg1, arg2 = None
    return inner_func

For 'func':

• arg1 and arg2 are bound variables

• arg1 is a cell variable since it is a free variable inside of 'inner_func'

• There are no free variables.

func.__code__.co_varnames

('arg1', 'arg2', 'inner_func')

func.__code__.co_cellvars

('arg1',)

func.__code__.co_freevars

()

For 'inner_func':

• arg3 is a bound variable

• arg1 is a free variable

• There are no cell variables

inner_func.__code__.co_varnames

('arg3',)

inner_func.__code__.co_freevars

('arg1')

inner_func.__code__.co_cellvars

()


问:
Show Videosignal in .Net WPF/DirectX
I have a videosignal that provides me a buffer with a YCbCR-Signal. I can convert it to RGB by doing some math but I have no idea how to show the video in ,Net WPF. I also tried to use SlimDX and render the stream to a sprite but this is only an idea and I also don't have a clue how to start.

Thanks for help,
Meldur

答:
If you can convert it to RGB, you have Bitmap in your hands. You can lock bitmap and set it's data. When you creating new Bitmap, you can set pixel format (24bpp, 32bpp), so creating Bitmap from video frame shouldn't be problem.

Every time you get new frame, all you need is to update texture in DirectX. Textures in DirectX has various formats and some of them are compatible with bitmap formats, you can even create new texture using Bitmap.

First find some examples how to render texture in DirectX (SlimDX, ManagedDirectX...), then update texture every time new frame comes in. If you don't want to bother with texture locking and updating, you can create new texture every time new frame comes, using this constructor

```<code>public Texture(Device, Bitmap, Usage, Pool);
</code>```

Even if you don't want to bother with DirectX, you can render directly into Canvas in WPF

```<code>class MyCanvas : Canvas {
protected override void OnRender (DrawingContext dc) {
      BitmapImage img = ...;
      dc.DrawImage (img, new Rect (0, 0, img.PixelWidth, img.PixelHeight));
   }
}
</code>```

To get BitmapImage from Bitmap, look here link text

ContentLicense: CC BY-SA 2.5

Title: Show Videosignal in .Net WPF/DirectX

Body:
If you can convert it to RGB, you have Bitmap in your hands. You can lock bitmap and set it's data. When you creating new Bitmap, you can set pixel format (24bpp, 32bpp), so creating Bitmap from video frame shouldn't be problem.

Every time you get new frame, all you need is to update texture in DirectX. Textures in DirectX has various formats and some of them are compatible with bitmap formats, you can even create new texture using Bitmap.

First find some examples how to render texture in DirectX (SlimDX, ManagedDirectX...), then update texture every time new frame comes in. If you don't want to bother with texture locking and updating, you can create new texture every time new frame comes, using this constructor

public Texture(Device, Bitmap, Usage, Pool);

Even if you don't want to bother with DirectX, you can render directly into Canvas in WPF

class MyCanvas : Canvas {
protected override void OnRender (DrawingContext dc) {
      BitmapImage img = ...;
      dc.DrawImage (img, new Rect (0, 0, img.PixelWidth, img.PixelHeight));
   }
}

To get BitmapImage from Bitmap, look here link text


问:
Open Empty Command Prompt and Stay Open with Python
I want python to open an empty Command Prompt (cmd.exe) and leave it open without running anything. I want command prompt to open in a new window and this python code to continue running.

I have tried:

```<code>os.system("start C://Windows/System32/cmd.exe")
</code>```

And:

```<code>os.system("C://Windows/System32/cmd.exe")
</code>```

And:

```<code>os.system("start /wait C://Windows/System32/cmd.exe")
</code>```

And:

```<code>os.system("start /wait cmd /c")
</code>```

None of the above left Command Prompt open. I also want to be able to close it later (with python) by using:

```<code>os.system("taskkill /f /im  cmd.exe")
</code>```

Thanks for any help. I couldn't find an answer to this anywhere. This was the closest but this needed a command to be entered. I don't want a command to be entered before.

答:
I found out a few ways to do this. Firstly, there are 2 ways of opening command prompt. One is the normal Windows Command Prompt.The other way is by opening it with python as the input. There are a few ways for both.

For Python as the input:

```<code>os.system('cmd.exe /C start "Unique_name" cmd.exe')
</code>```

The "unique_name" is so that it can be closed with:

```<code>os.system('taskkill /F /IM "cmd.exe" /FI "WINDOWTITLE eq Unique_name"')
</code>```

The following also work:

os.system('cmd /C start cmd')

os.system('cmd /C start')

os.system('start cmd')

For Windows Command Prompt:

```<code>os.startfile("C://Windows/System32/cmd.exe")
</code>```

This can be closed with:

```<code>os.system("taskkill /f /im  cmd.exe")
</code>```

Body:
I want python to open an empty Command Prompt (cmd.exe) and leave it open without running anything. I want command prompt to open in a new window and this python code to continue running.

I have tried:

os.system("start C://Windows/System32/cmd.exe")

And:

os.system("C://Windows/System32/cmd.exe")

And:

os.system("start /wait C://Windows/System32/cmd.exe")

And:

os.system("start /wait cmd /c")

None of the above left Command Prompt open. I also want to be able to close it later (with python) by using:

os.system("taskkill /f /im  cmd.exe")

Thanks for any help. I couldn't find an answer to this anywhere. This was the closest but this needed a command to be entered. I don't want a command to be entered before.

Body:
I found out a few ways to do this. Firstly, there are 2 ways of opening command prompt. One is the normal Windows Command Prompt.The other way is by opening it with python as the input. There are a few ways for both.

For Python as the input:

os.system('cmd.exe /C start "Unique_name" cmd.exe')

The "unique_name" is so that it can be closed with:

os.system('taskkill /F /IM "cmd.exe" /FI "WINDOWTITLE eq Unique_name"')

The following also work:

os.system('cmd /C start cmd')

os.system('cmd /C start')

os.system('start cmd')

For Windows Command Prompt:

os.startfile("C://Windows/System32/cmd.exe")

This can be closed with:

os.system("taskkill /f /im  cmd.exe")


问:
RobotFramework: No new window at last index. Please use '@{ex}= | List Windows' + new > window trigger + 'Select Window | ${ex}' to find it
My requirement is, On click of a button in a window(parent window) it has to open a new window(popup window, child window) and I wrote a testcase for this.

But the issue is when the button on the parent window is clicked, my script fails and gives in the report/log as:

"No new window at last index. Please use '@{ex}= | List Windows' + new
  window trigger + 'Select Window | ${ex}' to find it."

Below is one of the userdefined keyword used in my testcase which is failing in Robot Framework:

```<code>Move To Chat Page
    Click Button                    Continue to ChatPage>>

    Select Window                   new
    Set Selenium Implicit Wait      6s
    Click Button                    //input[@type='submit'][@value='Continue with ChatBot']

    Set Selenium Implicit Wait      3s
    Click Element                   user.profileBean.issue
    Select From List By Value       user.profileBean.overrideIssue      2
    Click Button                    Continue to connect

    Set Selenium Implicit Wait  3s
    Select Window                   main
    Title Should Be                 XYZ
</code>```

Below is the screenshot of the same:

答:
When using windows it's best to use a unique Id, Name, Title or the URL of the popup. In the below example I have a simple index page which creates a popup.

index.html

```<code><html>
  <head>
    <title>main-window</title>
  </head>
  <body>
    <a href="http://localhost:8090/popup/popup.html" onclick="javascript:void window.open('http://localhost:8090/popup/popup.html','1496569988172','width=700,height=500,toolbar=0,menubar=0,location=0,status=0,scrollbars=0,resizable=0,left=0,top=0');return false;">Pop-up Window</a>
  </body>
</html>
</code>```

popup.html

```<code><html>
  <head>
    <title>popup-window</title>
  </head>
  <body>
     Pop!!
  </body>
</html>
</code>```

When using the following robot script the switch between the windows is made.

```<code>*** Settings ***
Library    Selenium2Library

*** Test Cases ***
Test popup
    Create Webdriver    Chrome
    Go To    http://localhost:8090/popup/
    Click Link    Pop-up Window
    Select Window    url=http://localhost:8090/popup/popup.html
    Log Title
    Select Window
    Log Title
    Capture Page Screenshot
    [Teardown]  Close All Browsers
</code>```

Which in this case will add the following items to the log file:

main-window

popup-window

Body:
My requirement is, On click of a button in a window(parent window) it has to open a new window(popup window, child window) and I wrote a testcase for this.

But the issue is when the button on the parent window is clicked, my script fails and gives in the report/log as:

"No new window at last index. Please use '@{ex}= | List Windows' + new
  window trigger + 'Select Window | ${ex}' to find it."

Below is one of the userdefined keyword used in my testcase which is failing in Robot Framework:

Move To Chat Page
    Click Button                    Continue to ChatPage>>

    Select Window                   new
    Set Selenium Implicit Wait      6s
    Click Button                    //input[@type='submit'][@value='Continue with ChatBot']

    Set Selenium Implicit Wait      3s
    Click Element                   user.profileBean.issue
    Select From List By Value       user.profileBean.overrideIssue      2
    Click Button                    Continue to connect

    Set Selenium Implicit Wait  3s
    Select Window                   main
    Title Should Be                 XYZ

Below is the screenshot of the same:

Body:
When using windows it's best to use a unique Id, Name, Title or the URL of the popup. In the below example I have a simple index page which creates a popup.

index.html

<html>
  <head>
    <title>main-window</title>
  </head>
  <body>
    <a href="http://localhost:8090/popup/popup.html" onclick="javascript:void window.open('http://localhost:8090/popup/popup.html','1496569988172','width=700,height=500,toolbar=0,menubar=0,location=0,status=0,scrollbars=0,resizable=0,left=0,top=0');return false;">Pop-up Window</a>
  </body>
</html>

popup.html

<html>
  <head>
    <title>popup-window</title>
  </head>
  <body>
     Pop!!
  </body>
</html>

When using the following robot script the switch between the windows is made.

*** Settings ***
Library    Selenium2Library

*** Test Cases ***
Test popup
    Create Webdriver    Chrome
    Go To    http://localhost:8090/popup/
    Click Link    Pop-up Window
    Select Window    url=http://localhost:8090/popup/popup.html
    Log Title
    Select Window
    Log Title
    Capture Page Screenshot
    [Teardown]  Close All Browsers

Which in this case will add the following items to the log file:

main-window

popup-window


问:
why there is "ï»¿" when doing file comparison
in the beginning of the file when doing diff.</p>

答: This is the UTF-8 signature (U+FEFF, aka. BOM: Byte Order Mark). Your editor has put it into the file.</p>


问:
isExecuting on HMActionSets always false
So far, I have implemented an application where I can create HMActionSets, and they get added to HomeKit, and they can also be executed, too (The values change accordingly in the Accessory Simulator). However, I'm facing a strange problem: whenever I call

```<code>func executeActionSet(HMActionSet, completionHandler: (Error?) -> Void)
</code>```

(I get back no error, and the actionset has been actually executed). However, then I go back and look through my HMHome.actionSets array again, and check the

```<code>isExecuting
</code>```

attribute -> But then it is always false.

Do you have any idea what I might be doing wrong?

答:
Sadly, I couldn't figure out why this attribute is always false.
However, I found a workaround if you want to know if a scene is being executed at the moment or not:

Simply go through all of the HMActions of the HMActionSet, check if the targetValue of the HMAction is the same as the current value of the associated characteristic, and only if all of the specified characteristics and values are the same, then you can say: HMActionSet XYZ is being executed. Apparently, that's how the official Home App also does it. (Found on the Apple Developer Forum for HomeKit)

Body:
So far, I have implemented an application where I can create HMActionSets, and they get added to HomeKit, and they can also be executed, too (The values change accordingly in the Accessory Simulator). However, I'm facing a strange problem: whenever I call

func executeActionSet(HMActionSet, completionHandler: (Error?) -> Void)

(I get back no error, and the actionset has been actually executed). However, then I go back and look through my HMHome.actionSets array again, and check the

isExecuting

attribute -> But then it is always false.

Do you have any idea what I might be doing wrong?


问:
Transfer data from one datatable to another datatable
I want to transfer data from one datatable to another . Like for example, for queue numbers, i have buttons for call, skip and enter. I want the data to transfer to another datatable when i press skip, and the queue number will go from the 'queue' datatable to 'missedQueue' datatable. But i do not know how to code it. Please help</p>

答:
If the destination table does not exist, the syntax is:</p>

```<code> SELECT * INTO missedQueue FROM queue
</code>```

Body:
If the destination table does not exist, the syntax is:

 SELECT * INTO missedQueue FROM queue


问:
Python string remove hex codes like in 'president trump\\xe2\\x80\\x99s'
I searched a while but couldn't find something helpful.
I try to delete these hex codes in strings in a Paython List, but can't figure out how to do that. They are in string format!
Except from my Data (Trump Twitter fetches):

```<code>tweets[7]
'rt @ lindseygrahamsc : i support president trump\\xe2\\x80\\x99s desire to reenter the paris accord after the agreement becomes a better deal for america\\xe2\\x80\\xa6'
</code>```

Thank You!

答:
Try this way, it only work to sub string '\\x**':

```<code>import re
tweets = 'rt @ lindseygrahamsc : i support president trump\\xe2\\x80\\x99s desire to reenter the paris accord after the agreement becomes a better deal for america\\xe2\\x80\\xa6'
re.sub(r'(\\x(.){2})', '',tweets)
</code>```

output:

```<code>'rt @ lindseygrahamsc : i support president trumps desire to reenter the paris accord after the agreement becomes a better deal for america'
</code>```

Body:
I searched a while but couldn't find something helpful.
I try to delete these hex codes in strings in a Paython List, but can't figure out how to do that. They are in string format!
Except from my Data (Trump Twitter fetches):

tweets[7]
'rt @ lindseygrahamsc : i support president trump\\xe2\\x80\\x99s desire to reenter the paris accord after the agreement becomes a better deal for america\\xe2\\x80\\xa6'

Thank You!

Body:
Try this way, it only work to sub string '\\x**':

import re
tweets = 'rt @ lindseygrahamsc : i support president trump\\xe2\\x80\\x99s desire to reenter the paris accord after the agreement becomes a better deal for america\\xe2\\x80\\xa6'
re.sub(r'(\\x(.){2})', '',tweets)

output:

'rt @ lindseygrahamsc : i support president trumps desire to reenter the paris accord after the agreement becomes a better deal for america'


问:
How to create a PopUpWindow in android which can be closed anywhere on the display?
how can I create a popupwindow, which only opens then I press a button, but closes when I tap anywhere on the screen?

In this PopUpWindow should only be text information.

Thank you

答: I think what you are looking for is alerDialog with setCancelable as true. Go through the android documentation https://developer.android.com/guide/topics/ui/dialogs.html. </p>


问:
Async behavior on WebForms gridview
While porting a legacy application to async\await pattern we've came across some weird behavior we can't track. We set the page async directive to true, and add event handler to RowDataBound. If the code in the EventHandler contains an awaited call, it is not awaited before moving on to handle the next row.

Here is a repro to make it easier to understand:

```<code>public partial class WorkingCorrectlyWebForm: System.Web.UI.Page
{
    private int _index;
    protected void Page_Load(object sender, EventArgs e)
    {
        var grid = new GridView();
        grid.RowDataBound += GridOnRowDataBound;
        grid.DataSource = new[]
        {
            new {Name = "Person1", Age = 23},
            new {Name = "Person2", Age = 33},
            new {Name = "Person3", Age = 15}
        };

        grid.DataBind();
    }

    private async void GridOnRowDataBound(object sender, GridViewRowEventArgs gridViewRowEventArgs)
    {
        if (gridViewRowEventArgs.Row.RowType != DataControlRowType.DataRow)
            return;

        var localIndex = ++_index;

        HttpContext.Current.Response.Write($"starting #{localIndex} <br />");

        await Task.Delay(1000); //HERE IS THE PROBLEMATIC LINE

        //removing the remark from the following line will make code behave "synchronously" as expected.
        // Task.Delay(1000).Wait();

        HttpContext.Current.Response.Write($"exiting #{localIndex} <br />");
    }
}
</code>```

This code will generate output that is similiar to this (instead of ordered "starting\exiting" each item):

starting #1

starting #2

starting #3

exiting #3

exiting #1

exiting #2

Why is this happeninig? why am i not seeing an ordered "starting" and "exiting" messages.

答:
If you want serial behaviour, this should work:

```<code>    private void GridOnRowDataBound(object sender, GridViewRowEventArgs gridViewRowEventArgs)
    {
        if (gridViewRowEventArgs.Row.RowType != DataControlRowType.DataRow)
            return;

        var localIndex = ++_index;

        HttpContext.Current.Response.Write($"starting #{localIndex} <br />");

        Thread.Sleep(1000);
        // or             Task.Delay(1000).Wait();

        HttpContext.Current.Response.Write($"exiting #{localIndex} <br />");
    }
</code>```

or try:

```<code>    private void GridOnRowDataBound(object sender, GridViewRowEventArgs gridViewRowEventArgs)
    {
        RegisterAsyncTask(new PageAsyncTask(() => Bob(gridViewRowEventArgs)));
        HttpContext.Current.Response.Write($"b");

    }

    private async Task Bob(GridViewRowEventArgs gridViewRowEventArgs)
    {
        if (gridViewRowEventArgs.Row.RowType != DataControlRowType.DataRow)
            return;

        var localIndex = ++_index;

        HttpContext.Current.Response.Write($"starting #{localIndex} <br />");

        await Task.Delay(1000);

        HttpContext.Current.Response.Write($"exiting #{localIndex} <br />");
    }
</code>```

Title: Async behavior on WebForms gridview

Body:
While porting a legacy application to async\await pattern we've came across some weird behavior we can't track. We set the page async directive to true, and add event handler to RowDataBound. If the code in the EventHandler contains an awaited call, it is not awaited before moving on to handle the next row.

Here is a repro to make it easier to understand:

public partial class WorkingCorrectlyWebForm: System.Web.UI.Page
{
    private int _index;
    protected void Page_Load(object sender, EventArgs e)
    {
        var grid = new GridView();
        grid.RowDataBound += GridOnRowDataBound;
        grid.DataSource = new[]
        {
            new {Name = "Person1", Age = 23},
            new {Name = "Person2", Age = 33},
            new {Name = "Person3", Age = 15}
        };

        grid.DataBind();
    }

    private async void GridOnRowDataBound(object sender, GridViewRowEventArgs gridViewRowEventArgs)
    {
        if (gridViewRowEventArgs.Row.RowType != DataControlRowType.DataRow)
            return;

        var localIndex = ++_index;

        HttpContext.Current.Response.Write($"starting #{localIndex}
");

        await Task.Delay(1000); //HERE IS THE PROBLEMATIC LINE

        //removing the remark from the following line will make code behave "synchronously" as expected.
        // Task.Delay(1000).Wait();

        HttpContext.Current.Response.Write($"exiting #{localIndex}
");
    }
}

This code will generate output that is similiar to this (instead of ordered "starting\exiting" each item):

starting #1

starting #2

starting #3

exiting #3

exiting #1

exiting #2

Why is this happeninig? why am i not seeing an ordered "starting" and "exiting" messages.

Body:
If you want serial behaviour, this should work:

    private void GridOnRowDataBound(object sender, GridViewRowEventArgs gridViewRowEventArgs)
    {
        if (gridViewRowEventArgs.Row.RowType != DataControlRowType.DataRow)
            return;

        var localIndex = ++_index;

        HttpContext.Current.Response.Write($"starting #{localIndex} <br />");

        Thread.Sleep(1000);
        // or             Task.Delay(1000).Wait();

        HttpContext.Current.Response.Write($"exiting #{localIndex} <br />");
    }

or try:

    private void GridOnRowDataBound(object sender, GridViewRowEventArgs gridViewRowEventArgs)
    {
        RegisterAsyncTask(new PageAsyncTask(() => Bob(gridViewRowEventArgs)));
        HttpContext.Current.Response.Write($"b");

    }

    private async Task Bob(GridViewRowEventArgs gridViewRowEventArgs)
    {
        if (gridViewRowEventArgs.Row.RowType != DataControlRowType.DataRow)
            return;

        var localIndex = ++_index;

        HttpContext.Current.Response.Write($"starting #{localIndex} <br />");

        await Task.Delay(1000);

        HttpContext.Current.Response.Write($"exiting #{localIndex} <br />");
    }