<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Thanks for your help. I in Intel® Distribution for Python*</title>
    <link>https://community.intel.com/t5/Intel-Distribution-for-Python/Force-the-use-of-one-thread-with-PyDAAL/m-p/1093233#M410</link>
    <description>&lt;P&gt;Thanks for your help. I appreciate.&lt;/P&gt;</description>
    <pubDate>Thu, 27 Apr 2017 13:55:06 GMT</pubDate>
    <dc:creator>velvia</dc:creator>
    <dc:date>2017-04-27T13:55:06Z</dc:date>
    <item>
      <title>Force the use of one thread with PyDAAL</title>
      <link>https://community.intel.com/t5/Intel-Distribution-for-Python/Force-the-use-of-one-thread-with-PyDAAL/m-p/1093231#M408</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I would like to make some benchmarks and force PyDAAL to use only one thread for k-means clustering. How can I do that?&lt;/P&gt;

&lt;P&gt;Best regards,&lt;/P&gt;

&lt;P&gt;Francois&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2017 11:08:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Distribution-for-Python/Force-the-use-of-one-thread-with-PyDAAL/m-p/1093231#M408</guid>
      <dc:creator>velvia</dc:creator>
      <dc:date>2017-04-27T11:08:43Z</dc:date>
    </item>
    <item>
      <title>Hi Francois,</title>
      <link>https://community.intel.com/t5/Intel-Distribution-for-Python/Force-the-use-of-one-thread-with-PyDAAL/m-p/1093232#M409</link>
      <description>&lt;P&gt;Hi Francois,&lt;/P&gt;

&lt;P&gt;The library includes an example called set_number_of_threads.py that should give you all the information you need. &amp;nbsp;I'll paste it here for convenience.&lt;/P&gt;

&lt;PRE class="brush:python;"&gt;from os.path import join as jp
from os import environ

import daal.algorithms.kmeans as kmeans
import daal.algorithms.kmeans.init as init
from daal.data_management import FileDataSource, DataSourceIface
from daal.services import Environment

# Input data set parameters
datasetFileName = jp('..', 'data', 'batch', 'kmeans_dense.csv')

# K-Means algorithm parameters
nClusters = 20
nIterations = 5
nThreads = 2
nThreadsInit = None
nThreadsNew = None

if __name__ == "__main__":

    # Get the number of threads that is used by the library by default
    nThreadsInit = Environment.getInstance().getNumberOfThreads()

    # Set the maximum number of threads to be used by the library
    Environment.getInstance().setNumberOfThreads(nThreads)

    # Get the number of threads that is used by the library after changing
    nThreadsNew = Environment.getInstance().getNumberOfThreads()

    # Initialize FileDataSource to retrieve the input data from a .csv file
    dataSource = FileDataSource(
        datasetFileName, DataSourceIface.doAllocateNumericTable,
        DataSourceIface.doDictionaryFromContext
    )

    # Retrieve the data from the input file
    dataSource.loadDataBlock()

    # Get initial clusters for the K-Means algorithm
    initAlg = init.Batch(nClusters)

    initAlg.input.set(init.data, dataSource.getNumericTable())
    res = initAlg.compute()
    centroids = res.get(init.centroids)

    # Create an algorithm object for the K-Means algorithm
    algorithm = kmeans.Batch(nClusters, nIterations)

    algorithm.input.set(kmeans.data, dataSource.getNumericTable())
    algorithm.input.set(kmeans.inputCentroids, centroids)

    # Run computations
    unused_result = algorithm.compute()

    print("Initial number of threads:        {}".format(nThreadsInit))
    print("Number of threads to set:         {}".format(nThreads))
    print("Number of threads after setting:  {}".format(nThreadsNew))&lt;/PRE&gt;

&lt;P&gt;Thanks,&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2017 13:24:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Distribution-for-Python/Force-the-use-of-one-thread-with-PyDAAL/m-p/1093232#M409</guid>
      <dc:creator>Christophe_H_Intel2</dc:creator>
      <dc:date>2017-04-27T13:24:28Z</dc:date>
    </item>
    <item>
      <title>Thanks for your help. I</title>
      <link>https://community.intel.com/t5/Intel-Distribution-for-Python/Force-the-use-of-one-thread-with-PyDAAL/m-p/1093233#M410</link>
      <description>&lt;P&gt;Thanks for your help. I appreciate.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2017 13:55:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Distribution-for-Python/Force-the-use-of-one-thread-with-PyDAAL/m-p/1093233#M410</guid>
      <dc:creator>velvia</dc:creator>
      <dc:date>2017-04-27T13:55:06Z</dc:date>
    </item>
  </channel>
</rss>

